attached mail follows:
What is the best practice for dealing with read-only data? Is it
possible to make an Entity Bean completely read-only?
*Integrating data:*
When I was working the JBoss release candidates and I needed to
integrate some data from a second/foreign database on JBoss I would just
use the @Column attribute and mark all of my fields, including id, as such:
@Column(name = "SomeColumnName", nullable = false, updatable = false,
insertable = false)
When I try this in glassfish I get:
Exception [TOPLINK-46] (Oracle TopLink Essentials - 2006.5 (Build 060511)): oracle.toplink.essentials.exceptions.DescriptorException
Exception Description: There should be one non-read-only mapping defined for the primary key field
[snip]
I guess I can live with making the primary key field insertable. But,
it would be comforting if there was a way that I could ensure in the EJB
persistence class code that my EJB wouldn't try to insert/update data in
my table. This way I could be sure that if I mistakenly try to use that
class to persist data down the road I won't shoot myself in the foot and
damage a database table.
I don't have many of these but they do come in handy when I try to
integrate (sensitive/finicky) data from an existing source into my
application. Is there a fast way or annotation that can be used inside
the EJB to ensure that no data will be written to any of the fields?
*How about in the case of reports? *
Does is make sense to prepare this data, say for a report, as a view in
sql and prepare an EJB to retrieve data from the view? In this scenario,
can an entity bean draw data on a view if the view has no natural keyid,
say for instance in a complicated join?
Up until now for reports I've been stuffing some sql into a method of a
session bean and returning a Result to the backing bean for eventual
display in a jsp/jsf page. This works fine but I wonder if the
application would seem more consistent if all the data interaction, even
the read-only, occurred via cmp style persistence.
What is considered the best practice for these two scenarios?
Dennis