Hi All,

I'm currently having a problem with reordering of written objects done by the org.apache.ojb.odmg.ObjectEnvelopeTable.reorder() method. I have implicit locking off, and I always "lock" objects in the order they would have to in order to maintain referrential integrity. That is, I don't think I would have a problem if I could disable "reordering" before committing a transaction. Is there a way to disable reordering?

The following is an attempt to describe my situation:

I currently have a bi-directional relationship between two objects. Say I have two classes A and B:

class A {
  private B currentB;
}

class B {
  private A a;
}

An A can have multiple B's, but it keeps a pointer to the current B, which is updated every time a new B for that A is created. This bi-directional relationship seems to cause problems for the ObjectEnvelopeTable.reorder() method. I.e., when doing the following (pseudocode):

beginTxn();

B b = new B();

a.setCurrentB(b);

lock(b); // corresponds to an INSERT into B's table
lock(a); // corresponds to an UPDATE on A's table, with a FK reference to the just-inserted B


commitTxn();

What ends up happening is that the UPDATE is happening before the INSERT, which fails because currentB's id is not yet defined. By playing with the order that I lock those objects and others within the transaction, I can sometimes get them to go in the right order, but this is hokey. The problem resurfaces when tearing down my unit tests, as the reordering at delete time can also get messed up. The following thread describes a similar problem to mine.

http://www.mail-archive.com/ojb-user@db.apache.org/msg05317.html

Anyway, I think if I could disable reordering, perhaps in the OJB.properties or something, I would cease to have this problem. The other obvious (but not really acceptable) solution would be to do these writes in separate transactions, making reorder()'s effects harmless.

Thanks in advance for any help,
Colin

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to