-->
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: Exception is NOT thrown immediatelty! Why?
PostPosted: Wed May 03, 2006 5:09 am 
Newbie

Joined: Tue May 02, 2006 10:22 pm
Posts: 8
I am using Hibernate 3.

If I execute "session.update" and the update is not successful (e.g. value too large), the exception is not thrown immediately.

For example,

System.out.println ("pass 1");
session.update(dataBean) ;

System.out.println ("pass 2");
session.getTransaction().commit();

System.out.println ("pass 3");

I find if session.update(dataBean) fails, "pass 1" and "pass 2" are printed but "pass 3" is not printed. That meams Hibernate will not throw exception until I execute "commit". Can I force it to throw immediately?


Thanks in advance.


Top
 Profile  
 
 Post subject: Flushing
PostPosted: Wed May 03, 2006 11:56 am 
Newbie

Joined: Wed May 03, 2006 6:25 am
Posts: 4
See:
http://www.hibernate.org/hib_docs/v3/reference/en/html/objectstate.html#objectstate-flushing

Try Session.flush() after session.update(dataBean) but nothing else is before the commit so just check the commit.

You can change flush mode (FlushMode).

Not sure why the default behaviour is not okay.


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