hi,

I've been using OJB for building a quick access layer to a database model and have stumbled across a problem which I could not find any answers in the docs or in this mailing list archives.

The problem is the following: most tables have the form

table a (
   a_id primary key,
   a_field unique
   b_field unique
)

with the primary keys being generated by a stored procedure in an Oracle DB.

I use OJB for queries, inserts and updates. For the first two it all went smoothly, but for update I have a problem: the users can update the field which is unique, to one that already exists in the DB, but has of course another PK.

When I do a broker.store() it executes clean, but in the broker.commitTransaction() it throws a TransactionAbortedException, although it befores prints a stack trace with something like

java.sql.BatchUpdateException: ORA-00001: unique constraint (TABLE.SYS_C001888) violated

where we can see that it's caused by a unique constraint violated.

But, in the code, when I do a| getSourceException() it returns null, so I can't get the information of what's the real reason of the transaction aborting.

I can do a query in OJB to see if there is any record with that unique field (equivalent to select count(a_field) from table where table.a_field = xxx) and avoid making the commit if I found a match, but if I have more than a candidate key, it's a little cumbersome.

Any ideas how I get the original exception??

thanks in advance,
Telmo.
|







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



Reply via email to