-->
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.  [ 2 posts ] 
Author Message
 Post subject: capturing hibernate exceptions before committing transaction
PostPosted: Fri Dec 10, 2004 3:04 pm 
Newbie

Joined: Thu Dec 02, 2004 12:06 pm
Posts: 2
Hi,

I am developing an application using Hibernate in combination with statless session beans. Whenever I persist data the code is executed withen a JTA transaction in the EJB container. As a result, any database or hibernate exceptions are thrown on committing the transaction.

The problem I am having is that if a database or hibernate exceptions are encounterd while committing the transaction a RollbackException is thrown. My code never gets the database or hibernate exceptions and only gets the RollbackException. The RollbackException does not provide any functions that gives me access to the originating exception. I can rollback the transaction but I can never now why.

The weblogic descriptor for entity beans has a flag called

delay-updates-until-end-of-tx

Setting this flag to FALSE will enable updates before the end of transaction. Therefore, if any integrity contraints exceptions are thrown I can detect them right away and know their source. I can choose to rollback the transaction too.

Does hibernate provide similar functionality?

Thanx


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 10, 2004 3:47 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Just do an explicit session.flush();

you could also try to use FlushMode.ALWAYS but that is rarely very efficient compared to handling it in the cases you want to find.

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.