> I think that this could be made into a pattern which could be generated by
> Torque.  I have one small problem with the code below though...it will
> create multiple Vendor instances which contain the same data.  For example
> if Model 1 and Model 2 both have Vendor 1, two Vendor Objects will be
> created that are both vendor 1.

Only matters when you actually rely on the fact that Model1 & Model2 both
have references to the _same_ object.  Otherwise it does not hurt.

> I would recommend adding the Vendors to a Hashtable, and then searching
with
> table.get(model.getVendorId()), and only if that returns null, doing
> VendorPeer.rowToObject.
>
> The main difficulty I can see for generalizing this is if the Class
contains
> many related classes.  Maybe each generated class which is the many side
of
> a 1 to many relationship should have a doSelectRelated which puts in all
the
> joins for getting the related classes. And the class which is the 1 side
of
> the 1 to many relationship would have a method void loadXXX which would
load
> the Vector of related objects. Then there could be a tag in the XML which
> would specify whether the loadXXX methods should be called when the
objects
> are created.
>
> What do you think of that?

With my implementation I tried to avoid multiple queries to the database to
try and get the best performance.  I tried something like the above and
although it worked I was not entirely happy with larger sets of queries (my
system has to be able to handle hundreds of vendors and thousands of
models).

The hashtable you mentioned also sounds a lot like the beginning of a
caching mechanism.  Just add some lazy loading and, hey presto we've got
Osage (previously OPAL) :-) :-)  Is there a place for this in Peers?  If we
decide to move in this direction we'll need to address all of the O-R
mapping questions that projects like Osage and Castor try to answer.

Probably depends on where you see Peers fit in.  Any thoughts / views on
this?  Where should Peer go in future?

~ Leon



------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to