• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

connection rollback/ atomic transaction problem

 
Nitin Deshmukh
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a problem. I am using JSF1.1, EJB2.x, JDBC and weblogic8.1sp6. the structure of the application is like this, jsf bean calls facade bean(which is stateless session bean) method. facade bean method calls dao method to perform database insert/updates. the trasaction attribute of facadebean's method is set to required in ejb-jar.xml.
now I create connection in the dao method and pass that to further dao methods. I have connection.setAutoCommit(false) in the dao methods. Problem is that in case of exception, rollback is not working. whatever updates are performed before the exception, get commited to the database, whether I specify rollback in the catch block or not. If I rollback in the dao method, I get the following exception when trying to rollback.
can anyone help me please?


here are my methods
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you calling setRollbackOnly() in your EJB method when you catch your application exception?
 
Nitin Deshmukh
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no, I am not. how do I call setRollbackOnly method? as far as I know, there is no such method in the session bean.
 
Nitin Deshmukh
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
found out that setRollBackOnly() is a method of EJBContext. used and tested this method in a dummy method and it seems to work.
thanks a lot for the response.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nitin Deshmukh:
hi,
found out that setRollBackOnly() is a method of EJBContext. used and tested this method in a dummy method and it seems to work.
thanks a lot for the response.


Yes indeed, it is called on the EJBContext. This is one of the cornerstones of EJB CMT. An EJB method that is running in a container managed transaction needs to know when an exception == a transaction rollback. It is perfectly possible for your method to handle a situation where you encounter an exception and you want the transaction to be committed anyway. So you need to tell the container that it should rollback via setRollbackOnly().
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic