db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matt Mastrangelo" <mm...@ccs.neu.edu>
Subject Foreign Key Assignment & reference retrieval
Date Wed, 11 Jun 2003 18:08:24 GMT

I'm experiencing a problem with foreign key values being set to null, and I
think it has to do with auto-retrieve being set to false in all of my
reference descriptors.  Here is how my setup works:

Since auto-retrieve is set to false for all reference descriptors in the
repository, I call broker.retreiveReference in the getters for all the
related objects in my persisted beans.  As such, a related object will only
be materialized when needed.  This is to prevent a ton of related objects
from being materialized when merely trying to display a list, for example.

A nasty side effect of this setup is that oftentimes, beans get cached with
the referenced objects having null values.  So when one of the beans is
pulled out of the cache, modified, and stored, the assertFkAssignment method
in PersistenceBrokerImpl sets the foreign key value to null!

Has anyone else experience this kind of issue?

On a side note, It seems presumptuous on the part of OJB to just delete a
foreign key value when a related bean cannot be materialized.  While this
functionality could be useful, having it as an option would be nice -- to
either leave the value as is, throw an exception, or delete it.

Thanks for your help.


View raw message