-->
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: Selective session flushing ?
PostPosted: Tue Nov 01, 2005 4:20 pm 
Newbie

Joined: Tue Nov 01, 2005 4:13 pm
Posts: 1
Hi,

Looking at the Session API, one notices that it is possible to selectively load, save and delete specific objects. However, the flush() method indiscriminately synchronizes the cache with the underlying database.

This poses problem for the application I'm working on since we would like to be able to flush changes that happened on specific objects only, not all dirty objects found in the cache. Is there a way to accomplish this ? Is there a clear reason why flush() isn't selective, and if not can we expect that it could become selective in future Hibernate releases ?

Thanks in advance for a response,
Louis-Frederic Huppe-St-hilaire


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 01, 2005 5:37 pm 
Regular
Regular

Joined: Mon Jul 26, 2004 2:28 pm
Posts: 86
Location: Pensacola, Florida
There are three ways to selectively synchronize state with the database that I know of:

1. Use the session-per-request pattern (close session on each request). Load the objects on one request and save them in another. This means that most of the time you will be working with detached objects (objects that are not known to the session--objects become detached when the session is closed). You can call session.save( ), session.update( ), etc. in a subsequent request on the objects you want synchronized, and leave the others detached.

2. Evict (detach) the objects that you do not want persisted

3. Use multiple sessions. Only flush the session that you want synchronized


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.