[OJB-developers] Bug in ODMG transaction
Brought to you by:
thma
From: Bischof, R. <rai...@ed...> - 2002-03-05 15:56:38
|
Hi, I just moved to the current release which should fix some bugs with foreign keys and the ODMG interface. I discovered two more: 1. Object A references Object B of a different class in a 1-1 relationship. A's PK consists only of the reference to B (i.e. B's PK, which is auto-incremented). Both objects are newly created and properly locked with the ODMG transaction. B's PK is incremented at that time but A's FK to B is not updated at that time (this is done only in broker.store). Therefore A's FK to B is 0 which does not work. OJB places a lock on an object whose PK is not yet defined. Solution: FKs must be assigned before the lock is performed. I modified the TransactionImpl to do this by copying the methods of the broker that perform that to the TransactionImpl. That's just a quick and ugly hack but works. 2. Object A holds a collection of Bs. Auto-Update is set to true in the repository. I create A and lock it, than I create some Bs, lock them and add them to A's collection. On commit the ObjectEnvelopeTable first stores A which also stores it's collections. Afterwards the ObjectEnvelopeTable goes through the ObjectEnvelopes of all Bs. All of these Bs have a StateNewDirty which always creates INSERT statements. But the Bs have already been stored as part of A's collection. I currently do not have the time to provide a proper fix for this ( I just switched of AutoUpdate and it worked for me). Regards Rainer |