-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: CaveatEmptorFacadeBean and sessionContext.setRollbackOnly()
PostPosted: Fri Aug 06, 2004 3:36 am 
Expert
Expert

Joined: Fri Feb 06, 2004 7:49 am
Posts: 255
Location: Moscow, Russia
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/Session6.html#wp80322
Quote:
If a system exception occurs within a transaction, the EJB container rolls back the transaction. However, if an application exception is thrown within a transaction, the container does not roll back the transaction.


now CaveatEmptorFacadeBean looks like:
Code:
public Bid bidForItem(Long userId, Long itemId, BigDecimal bidAmount) throws RemoteException {
try {
    //...
    HibernateUtil.commitTransaction();
}
finally {
    HibernateUtil.closeSession();
}


I think it should look like:
Code:
bidAmount) throws RemoteException {
try {
    //...
    HibernateUtil.commitTransaction();
}
catch (InfrastructureException e) { // or any another base application   level one
   sessionContext.setRollbackOnly(); // to tell container to rollback current transaction
}
finally {
    HibernateUtil.closeSession();
}


I don't know if hibernate Transaction.rollback() inside CMT rollbacks/marks current CMT transaction with sessionContext.setRollbackOnly()?

--
Leonid


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 06, 2004 3:39 am 
Expert
Expert

Joined: Fri Feb 06, 2004 7:49 am
Posts: 255
Location: Moscow, Russia
Code:
catch (InfrastructureException e) { // or any another base application level one
   sessionContext.setRollbackOnly(); // to tell container to rollback current transaction
   throw e;
}


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 06, 2004 5:22 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Transaction.rollback() does this.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.