-->
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.  [ 1 post ] 
Author Message
 Post subject: Errors lost in TransactionSynch?
PostPosted: Tue Oct 05, 2004 5:00 pm 
Newbie

Joined: Tue Oct 05, 2004 4:33 pm
Posts: 4
Location: Trondheim, Norway
I've fetched the latest hibernate code from jboss' CVS and have deployed it in JBoss 3.2.x. If this is a really bad idea, please let me know.

The problem though, is that if my EJB inserts an object into the database using session.save(object) the object is not actually stored in the database yet.

The object isn't stored in the database until TransactionSynch.beforeCompletion() is called:

Code:
         try
         {
            log.trace("Flushing Session");
            session.flush();
         }
         catch(Throwable t)
         {
            log.warn("Error flushing session");
         }


Now, if anything goes wrong, like if there is already an object with that primary key in the database, the duplicate key exception is lost in the catch, and the EJB method caller will never know that something wrong happened!

Is this really what is intended? Or am I using this wrong?

Do I need to flush() the session manually at the end of each of my EJB methods, or will rethrowing the exception in beforeCompletion() be a better approach?



Eivind


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

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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.