db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bart Molenkamp" <b.molenk...@bizzdesign.nl>
Subject RE: [ODMG] Making graphs with M:N relations persistent
Date Tue, 08 Feb 2005 07:30:07 GMT
Hi Armin,

I solved the problem by becoming a listener of the persistence broker.
On the afterBegin() event, I store my objects (the M side and the N
side, not the relation between them) and then mark them dirty on the
ODMG transaction.
When I commit the ODMG transaction, it calls the afterBegin() before
doing anything else. The ugly thing about this is that I have to know
how my objects look without any relations, so all my persistent classes
implement an interface to clone the object without any relations. Not
very nice, but it is a very quick way.

I'll see if I can help doing this the right way. I'm not (very) familiar
to OJB's internals, I'll start looking at the
ObjectEnvelopeTable/ObjectEnvelope as you said.

Thanks so far,
Bart.

> -----Original Message-----
> From: Armin Waibel [mailto:arminw@apache.org]
> Sent: Friday, February 04, 2005 11:39 PM
> To: OJB Developers List
> Subject: Re: [ODMG] Making graphs with M:N relations persistent
> 
> 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


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