Found this in Hibernate wiki

So, in our example above, if we have to evict the Parent with id 500
and its collection from the second level cache, then here’s what has
to be done:
SessionFactory sf = MyUtil.getSessionFactory();
sf.evict(org.myapp.ho.Parent.class,new Integer(500)); //this will
evict the Parent Object from the second level cache
sf.evictCollection(org.myapp.ho.Parent.class.getName() +
“.myChildren”, new Integer(500)); //this will evict the collection
from the second level cache for the Parent with id=500
The first parameter to the evictCollection method is the ‘roleName’ of
the collection. The roleName is formed as follows:
roleName = NameOfTheParentClass + “.” +
NameOfTheCollectionInsideTheParent
The second parameter the evictCollection method is the id of the
parent object, to which this collection belongs.

On Sep 21, 7:51 am, epitka <[email protected]> wrote:
> I am not sure I understand how EvictCollection works. In the documents
> there is this example.
>
> sessionFactory.EvictCollection("Eg.Cat.Kittens", catId); //evict a
> particular collection of kittens
>
> 1. Let's say I have  Cat, that has a two collections of Kittens named
> WhiteKittens and BlackKittens. Will it remove both from second level
> cache
>
> 2. What if I have two object of different type with a same id (BigCat
> and SmallCat) with id of 100 and both have collection of Kittens. What
> will be removed from second level cache.
>
> 3. Is this catId acutally supposed to be instance of the object that
> has a collection, rather than id of the object?

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to