-->
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.clear() or evict() for all InstancesOf
PostPosted: Wed Nov 09, 2005 7:14 am 
Newbie

Joined: Wed Nov 09, 2005 5:28 am
Posts: 3
hibernate reference doc recommends the following code for batch inserts:

Code:
for ( int i=0; i<100000; i++ ) {
   Customer customer = new Customer(.....);
   session.save(customer);
   if ( i % 20 == 0 ) { //20, same as the JDBC batch size
      //flush a batch of inserts and release memory:
      session.flush();
     session.clear();
   }
}


the Problem is that i do not want to clear the whole session cache, i only want to eliminate the batch-inserted objects.
Instead of calling session.clear(), i'd like to havel something like
Code:
session.clear(Customer.class)
or
session.evict(Customer.class)


i haven't found any of those methods or something equivalent in Hib3rc2 ... any chance for such a method in a future release?
or is there any way to clear all InstancesOf without calling session.evict(Object) for every object?


Top
 Profile  
 
 Post subject: 2c
PostPosted: Wed Nov 09, 2005 3:39 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
I think that
s.getStatistics().getEntityKeys() might be used to get list of all objects in the session cache and then it could be filtered of course by entity type, so it looks like it is quite easy to create a function that will evict objects one by one, but on the appearance it will look like evictAll( String entityName, Session session ).

IMO: that should be on the application level, not in the H

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


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.