[jboss-user] [JBoss Cache] - Understanding JBossCache - Caching an object graph with many associations

Oliver Weiler do-not-reply at jboss.com
Thu Jul 28 10:14:17 EDT 2011

Oliver Weiler [http://community.jboss.org/people/helpermethod] created the discussion

"Understanding JBossCache - Caching an object graph with many associations"

To view the discussion, visit: http://community.jboss.org/message/618113#618113

I'm trying to use JBossCache as a JPA/Hibernate 2nd level cache provider to cache repeatedly called queries. The queries return entities of a specific type, lets call it FooType.

FooType looks like the following:

@Entity(name = FooType)
 @Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
 public class FooType {
  protected BarType barType;

  @ManyToOne(targetEntity = BarType.class, cascade = { CascadeType.ALL })
  BarType getBarType() { 
    return barType; 

So, Footype has a many-to-one association. Now, when I call the query, only a very small part seems to be put in the cache. I think the reason is because I didn't mark the association with the @Cache tag. Am I correct?
But the real question is:
BarType also has a handful of associations, and these return objects which also provide associations and so on, building a big graph of associations. Now, do I need to
a) annotate all of those classes and b) also annotate the associations
in order for the whole query to be cached?

Reply to this message by going to Community

Start a new discussion in JBoss Cache at Community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110728/e60482e9/attachment.html 

More information about the jboss-user mailing list