ObjectDB ObjectDB

Cannot catch a PersistenceException and continue the transaction


I try to create a factory that creates new objects just in case it doesn't find the relevant one in the DB.

but because query.getSingleResult() fires NoResultException in that case it marks the transaction as one that need to be rolled back. I understood that I can overcome it in several ways but those don't work for me.

  1. Begin a new (nested) transaction in another method that will be rolled back instead of the first one- doesn't work. I got a message that it couldn't begin a new transaction when another is active.
  2. Searching the relevant object outside a transaction using @TransactionalAttribute(TransactionType.NOT_SUPPORTED) - doesn't work for me because i need to find also objects created in the same transaction.
  3. Implement a BMT- it doesn't let me commit and rollback because the server is also trying to do so.

How can I do so?


I use Glassfish open source ee6 edition, eclipse juno on Windows 7 64


Hope to get a n usefull answer,

Ophir :)


You may catch the exception in the method.

If the exception is caught by the application and not thrown to the application server, the transaction is not expected to be marked for rollback.

ObjectDB Support

Ohh, I see.




To post on this website please sign in.