db-ojb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guillaume Laforge <glafo...@gmail.com>
Subject PB and Oracle9i: transaction issue
Date Fri, 05 Aug 2005 14:12:13 GMT
Hi all,

I'm having some issues with the PersistenceBroker.

I've got a one-to-many relationship, say a sentence, which has got
localized labels (1 sentence <-> several multilingual labels).

I want to store a new sentence with a new set of labels.
But I want to do that in a single transaction, so that if something
fails, I can rollback everything.

So, somewhere in my code, I'm doing a broker.beginTransaction().
I store my sentence. I create some labels a bit further and store them.
And later, broker.commitTransaction().
And in case something fails, I'm rollback-ing the transaction in some
try catch finally surrounding my code.

If autocommit is true, then my sentences and labels are stored... but,
unfortunately, if something goes wrong, OJB won't rollback anything.
So autocommit to true is not a good option for me since I want a real
transaction (I also tried setting autocommit on the broker object
itself but that wasn't any better).

If I set useAutoCommit="2" in my jdbc-connection-descriptor, I store
my sentence, but just after I see a weird message in the logs:

accesslayer.ConnectionManagerImpl  - Release connection: connection is
in local transaction, missing 'localCommit' or 'localRollback' call -
try to rollback the connection

And then, when I try to store the first label, I get an exception:

org.apache.ojb.broker.KeyConstraintViolatedException: SQL failure
while insert object data for class com.foo.bar.Xxxx, PK of the given
object is [ id=201], object was xxxx, exception message is [ORA-02291:
integrity constraint  (AE6.SYS_C001821) violated - parent key not

The message basically means that it can't find the sentence primary
key that the label is referencing (foreign key).

Background: I'm using OJB 1.0.3 and Oracle 9i with the thin driver.

So, I was wondering how I could store a new sentence and label in on
transaction and be able to rollback everything if I so desire?

Guillaume Laforge

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

View raw message