Announcement Announcement Module
Collapse
No announcement yet.
Hibernate - evict collection Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hibernate - evict collection

    Hi

    I am using Spring 1.2 and Hibernate 3.0.5.

    I would like to evict a collection in a class, how can I do that with HibernateTemplate or in HibernateCallback?

    Hibernate's SessionFactoryImpl has the evictCollection method, I couldn't find anything like that in Spring.

    I tried to evict the class that has the collection and hoped that it would evict the collection as well but it didn't.

    Thanks

  • #2
    (pseudo-code, don't have the interface memorized)

    Code:
    template.execute(new HibernateCallback() {
     public Object doInHibernate(Session ses) {
       ses.getSessionFactory().evictCollection(myColl);
      return null;
     }
    });
    ...or something like that. Note that according to the docs, the evict* methods on SessionFactory evict the object from the *second-level* cache, not the session-level cache.

    Comment


    • #3
      Excellent, exactly what I needed, thanks. :P

      Comment

      Working...
      X