Hi,

> I am using a home-grown persistence layer in my current 
> project. It gets the
> job done but has gotten to the stage where taking it forward 
> will be much
> more expensive than grabbing something like OJB for future 
> projects. But
> there is one thing (isn't there always?) about it that I really like.
> 
> Let's say that I have an Employee table with a need to link 
> to a department.
> Following some semblance of 3NF I have a distinct department 
> table that has
> an OID and a Name column. The Employee table simply uses the 
> OID. I then
> create a nice little VIEW that has all of the employee data 
> joined with the
> department data in a human readable form. I use this VIEW as 
> the source when
> loading up my employee objects from the database and there is 
> a read-only
> attribute for the department name. Very nice. That means that 
> I only have
> one database hit and no extra coding to get all of that 
> information out of
> the database and into the object for display in a JSP.
> 
> Obviously that is a very simplistic example but it leads me 
> to expanding to
> say that there are some VIEWs that you cannot insert into because of
> relational integrity issues. I am going to waffle here and 
> say that I don't
> completely understand what is going on here because my SQL 
> skills are far
> from spectacular but my DBA wagged his finger at me when I 
> told him what I
> was trying to do. I had to set up my objects so that instead 
> of attempting
> to insert into the VIEW they were inserting into the Employee table.
> 
> Based on that example I have to ask
> 1) Does OJB have the concept of read-only attributes? I think so but I
> haven't gone digging far enough.

No

> 2) Can I specify that an object be persisted to a different 
> table than it
> was read from which would allow me to select from a view and 
> insert into a
> table?

Not in declaratory way. you'll need some coding for this.

For the readphase you can use a class-descriptor that tell OJB to load the
class from a view.
And for the write phase you might use a different class-descriptor that
contains information to store the data into two tables.
 
> If I can't do #2 above then how would you suggest solving the 
> problem of
> getting all the joined data into the object so I only have to make one
> database hit?

OJB provide several optimizations to efficently load associatiated objects.
We have a proxy for lazy loading.
We have prefetched loading for improving loading of 1:n assosiations.
Normally these techniques will be sufficient to provide a good performance
for scenarios that you describe.

As an alternative you might consider to use the OJB Reportqueries.
Reportqueries do not materialize real business entities but are ment to
provide atabular representation of view data.

checkout PersistenceBroker.getReportQueryIteratorByQuery(...)

cheers,
Thomas

> rjsjr
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: 
> <mailto:[EMAIL PROTECTED]>
> 

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to