This is "the" reason for the EntityManager.flush() method that gives you immediate feedback if there is some application reason to fail the transaction.

If flush() succeeds, the only reason for failing a transaction is outside your (application) control.

Craig

On Jul 3, 2008, at 8:57 AM, Dirk Brenckmann wrote:

Hi,

Q: Is there a way to access/get back exceptions thrown within the persistance/transaction layer?

Example:
   Code (pseudo):
Sateless session bean::SomeEntity someMethod( SomeEntity entity ) {
                     return this.getEntityManager().merge( entity );
        }

   Server:
        Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException:
Duplicate entry '0-shortname 1-0000-00-00 00:00:00' for key 2

   Client:
        Will get SomeEntity with all fields set to null/default.


Well - I would have expected something like 'null' to be returned or an exception to be thrown, but I have to admit I did not yet fully read the specs... Nvm I can handle the returned value anyway.
But:
I'd like to give the user a feedback like "... already exists!" which I can do soley if I get access to the exception thrown on the transaction layer. Is there something like @TransactionCallback?
Or maybe I went wrong somwhere else?

Thank you in advance.
--
Psssst! Schon das coole Video vom GMX MultiMessenger gesehen?
Der Eine für Alle: http://www.gmx.net/de/go/messenger03

Craig L Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:[EMAIL PROTECTED]
P.S. A good JDO? O, Gasp!

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to