0

To rollback when have error, I use javax.ejb.SessionContext to do that,

first I mark a point to rollback by sessionContext.getUserTransaction().begin()

Then I use sessionContext.getUserTransaction().rollback() to rollback and use sessionContext.getUserTransaction().commit(); to should complete transaction before returning.

but the problem is if there is nothing changed, this will throws org.hibernate.exception.GenericJDBCException: could not prepare statement. Conclusion: There is anyway to stop SessionContext ?

Tejas Pandya
  • 3,987
  • 1
  • 26
  • 51
Fes Nguyen
  • 580
  • 5
  • 18
  • Are you really using EJBs? Because, the whole point of using EJBs is that you never need to manually deal with user transactions. So far it looks like your application is seriously wrongly configured, or that you don't understand how to use EJBs correctly. – BalusC Dec 28 '17 at 17:55
  • Thanks for your information, I also confuse about "is it the right way to deal with rollback?" Thanks ^_^. – Fes Nguyen Dec 29 '17 at 01:14

0 Answers0