db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Armin Waibel <arm...@apache.org>
Subject Re: [ODMG] Making graphs with M:N relations persistent
Date Fri, 04 Feb 2005 22:38:57 GMT
Hi Bart,

Bart Molenkamp wrote:
> Hi,
> 
> I've read in the release-notes.txt file that persisting graphs with M:N
> relations is not possible and is a known issue. It works when I create
> objects without the relations, store them using the persistence broker,
> then add the relations and lock them, so that the ODMG transaction
> stores the objects with the relations.
> 
> That work-around is fine for me, except that an ODMG transaction is not
> the same thing as a PB (database) transaction. Using the PB's store()
> method stores the object directly in the database (which is not what I
> want, I want it to be stored when ODMG transaction's commit() is
> called).
> 
> Two questions:
> 1. How difficult is it to fix this m:n issue in ODMG?

It will be tricky, because the odmg-implementation can't use the 
auto-xxx feature of the PB-api to handle m:n relations, thus we have to 
deal with the indirection table write/delete queries on odmg-level.
On insert first store n and m side, then write to indirection table. On 
delete vice versa,....

> Where should I
> start looking? I'll be happy if I can fix it and donate a patch!

Start looking in ObjectEnvelopeTable/ObjectEnvelope. I will start 
refactoring/fixing of known issues in odmg-api ASAP (hope to check in a 
first version in next two or three weeks). Any hints and help will be 
welcome.


> 2. If it is difficult (which it probably is ;), what would be the best
> strategy to intercept in an ODMG transaction's commit() and then use the
> persistence broker then as workaround (so that my whole graph of objects
> is stored inside a single database transaction)?
> 

This shouldn't be a problem, try

// cast to OJB extensions
TransactionExt tx = (TransactionExt)...get Transaction
tx.beginTransaction();
... do your odmg work

PersistenceBroker pb = tx.getBroker();
// do insert m:n relations using PB-api
// !!! don't close the used PB!!!

...
tx.commit()

good luck!

regards,
Armin

> Thanks,
> Bart.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message