• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

connection rollback/ atomic transaction problem

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you calling setRollbackOnly() in your EJB method when you catch your application exception?
 
Nitin Deshmukh
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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().
 
reply
    Bookmark Topic Watch Topic
  • New Topic