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.
- 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.
- 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.
- 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 22.214.171.124 open source ee6 edition, eclipse juno on Windows 7 64
Hope to get a n usefull answer,