• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to avoid automatic rollback?

 
Liwuen Chew
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody! First I would like to tell you that I found very useful this forum.
Well, I have a question, and I hope someone could help me.
Recently I found that, when running an application with EJB3 (hibernate + Oracle 10g), there is something rare happening. I make several inserts to Oracle (different tables), and use the entitymanager.flush() after each one. I found that, if for some reason one of them fails, it automatically makes a rollback to all the previous inserts, plus blocks something and Hibernate is not able to make the rest of pending inserts. Every insert (or update, depending the case) has a flush, and they are defined in different places along my code. How can I avoid this problem? How can I, for example, if something wrong happens in an insert, to keep the previous persisted data and continue making the rest of inserts?
I am using the annotation @TransactionAttribute(TransactionAttributeType.SUPPORTS) in each method where I access my entity manager. Can anyone help me? Thanks!

BTW: When trying to make the rest of inserts after the problem, I get the exception:'javax.persistence.TransactionRequiredException: EntityManager must be access within a transaction'
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is just how CMT will behave if you make numerous inserts in one transaction. If you need it to behave differently, call seperate CMT methods for each insert.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic