• Post Reply Bookmark Topic Watch Topic
  • New Topic

Invoking commit() from CM transactions

 
Ravi Singh
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you invoke commit e.g. con.commit(), from a bean which has its transactions managed by the container what happens?

Is the commit action performed or is the commit action ignored?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is an easy way to find out...

But why are you doing this? If you delegate transaction management to the container it is because you don't need to programatically control them. If you find you do then you shouldn't bne using container managed transactions for that method.
 
PNS Subramanian
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This was the exact situation which i had encountered.
Ironically, although J2EE specs say that con.commit() should not be called for EJB's whose transaction is managed by the container no exception is raised when we use commit, rollback in a bean whose transaction is managed by the container (here the attribute value is not set).
If anyone knows why, i would like to know.
 
Ravi Singh
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The reason I'm asking is because I'm trying to get a better understanding of the way a container manages transactions.

If the con.commit() doesn't throw an exception, is the statement simply ignored?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!