-->
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: session.flush() usage and issues
PostPosted: Thu Jun 01, 2006 4:55 am 
Newbie

Joined: Thu Jun 01, 2006 3:17 am
Posts: 2
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate3.0.1

Oracle9i

Hi Guys,

We have problem with session.flush() usage.We are using the session-per-request pattern.We call session.flush() even when we are fetching objects from DB and also when are persisting them to DB.My question is should we explicitly call session.flush() when we are listing the objects using query.list() , session.get() ,criteria.list() calls ?What is the ideal scenario where it has to be called ?How should we keep our session in sync with DB always ?

Thanks ,
Neil.
OSI Technologies.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 01, 2006 5:31 am 
Expert
Expert

Joined: Thu May 26, 2005 9:19 am
Posts: 262
Location: Oak Creek, WI
Call session.flush() when you persist the object to the DB.

i.e)
session.save(obj)
session.flush()

session.saveOrupdate(obj)
session.flush()
session.update(obj)
session.flush()

session.delete(obj)
session.flush()


So that you can see the inserted record in the list when you retrieve from the table.

_________________
RamnathN
Senior Software Engineer
http://www.linkedin.com/in/ramnathn
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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.