On Sat, Jul 08, 2000 at 04:53:29PM +0200, Leon Messerschmidt wrote:
> Hi
> 
> There is some functionality which might be useful to the generated peer
> classes, but I might need some slight changes to the table/column mapping
> classes, so that columns know if they are used as foreign keys in other
> tables.
> 
> My proposal is for 1:M relations: Basically the idea is that if a table
> (call it A) has a column that is used as a foreign key in another table
> (call it B) the A data object will have a method that does a query and
> return a vector with related B data objects.  The other way round B will
> have a method that returns it's master A object.

Yes this is a great idea. I have some perl scripts that do something
similar, so it is certainly feasible.

I was planning to look at adding this functionality to NGMBT myself, but
I haven't had any time to look at it yet - so please go ahead :-)

> To avoid overhead and the unnecessary loading of objects from database the
> query is only done once the method is called.  In other words only when A's
> getBobjects() method is called the query is actually executed and the B
> objects loaded.  In fact these methods are merely utility methods that does
> queries for that particular table's relations for you...

Yes - I believe that lazy querying is the right way to go. Have you
thought about updating? 

My current system has a setBobjectIds(int[] ids) to replace the set
mapped to. Then the data object has an int[] field for these ids - the
field starts out null, and if an array gets stored there when the object
is saved the new set mapped to gets persisted to the mapping table.

-- 
Sean Legassick
[EMAIL PROTECTED]
                                  homo sum: humani nihil a me alienum puto



------------------------------------------------------------
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