This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

evict() method doubt

 
Joe Harry
Ranch Hand
Posts: 10045
3
Eclipse IDE Mac PPC Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

Why would I need this method? Why would I clear off the cache using this method, in the following scenario that I got from the Hibernate Quickly book,

Event one = (Event) session.load (Event.class, eventId);
one.setName ("Culturals");

if (session.contains(one)) {
session.evict ();
}

Event two = new Event ();
two.setId (eventId);
two.saveOrUpdate ();

Is it for the reason that I simply want to associate the id with another instance, I use the evict () method?
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, lots of reasons to use evict. If you load too many objects into the Session you can run out of memory. So if you end up doing any long running sessions, you might want to evict out objects to save memory. It is a method that allows you full control over the cache's. There is also an evict() method in the Factory class to remove objects from the second level cache, if you are using second level cache.

Hope that helps clarify things for you.

Mark
 
Joe Harry
Ranch Hand
Posts: 10045
3
Eclipse IDE Mac PPC Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mark. Totally understood!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic