-->
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.  [ 4 posts ] 
Author Message
 Post subject: Second Level Cache functionality confirmation
PostPosted: Fri Aug 31, 2007 3:17 am 
Newbie

Joined: Sun Apr 22, 2007 5:49 pm
Posts: 5
Consider two tables

Customer and Items;

On the Customer entity I enabled second level cache for getItems();

Can any one please confirm when will the cached set of Items for Customer be removed from the cache.

(1) When a new Item is added or ant existing Item is updated.
(2) When a new Item is added and the new Item is also associated to Customer, or an existing Item that is associated to Customer is updated.

Please let me know which one of the above will invalidate the cache.





I would prefer the option (2).

As I want the Customer.getItems() to be in cache and I do not care if a Items table is updated with a new Item that is not associated to Customer, my cache should not be effected.

If I want to achive the above use case what do I need to do?

Thanks,
Naseer.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 03, 2007 8:25 pm 
Beginner
Beginner

Joined: Tue Apr 25, 2006 10:46 am
Posts: 28
http://www.javalobby.org/java/forums/t19807.html

and

http://forum.springframework.org/showthread.php?t=29691

HTH


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 07, 2007 5:27 pm 
Newbie

Joined: Sun Apr 22, 2007 5:49 pm
Posts: 5
I still did not get the answer to my question,

I am looking for a way to invalidate second level cache only if there is the contents cached are changed, not if the referring table is updated.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 07, 2007 5:40 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
AFAIK, collection caches are removed if a cache setting for that region forces so or a cluster invalidation message is received by your cache. As in your case I believe you are fine. Hibernate does not actually cache object instances in a collection, and it only caches the keys to objects in an association. Therefore, if a new item is added to the system it has nothing to do with your collection cache. However, if an Item that is already in an association is updated you will get the updated Item object the next time you fetch the object from cache. To make things clear, imagine this example: You have three items in your cache:

[1]=[Soap]
[2]=[Bread]
[5]=[Milk]

and your customer is:

[1]=['Someone', 'Somewhere', [2,5]]

In this example [2,5] is the relation between items and the customer keyed 1.


Does this answer your question?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.