-->
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.  [ 1 post ] 
Author Message
 Post subject: ehcache + jgroups + hibernate 2nd level cache optimization
PostPosted: Fri Nov 06, 2009 10:03 pm 
Newbie

Joined: Fri Nov 06, 2009 9:47 pm
Posts: 1
Hi there,

I'm using ehcache 1.7.0 + jgroups 2.4.2 + hibernate 3.2.4.sp1.cp07 (as part of JBoss 4.3.0 GA EAP CP04) to do a clustered cache and I'm seeing some interesting behavior where there seems to be an optimization happening in the query/2nd level caches that is making the clustering act strangely.

I have two servers, A and B. Each of the operations is happening through Hibernate.
Code:
@NamedQueries({
   @NamedQuery(
      name="Member.FindByEmail",
      query="from Member memb where memb.email = :email",
      hints={
         @QueryHint(name="org.hibernate.cacheable", value="true")
      }
   ),
   @NamedQuery(
      name="Member.CountAllMembers",
      query="select count(*) from Member",
      hints={
         @QueryHint(name="org.hibernate.cacheable", value="true")
      }
   )
})
@Entity
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
public class Member implements Comparable<Object>, Serializable


The steps to reproduce:

A1: execute named query: Member.CountAllMembers.
B1: execute named query: Member.CountAllMembers.

A2: Insert a row into the Member table.
B2: Attempt to query for the newly added Member using Member.FindByEmail.

B2 fails to find the member. I can see that no database hit occur from my mysql query log. (Member)q.getSingleResult();... this throws a NoResultsException.

Here is the trick: If I run A1 again, then B2 can immediately find the member.

It seems there is an optimization on B that says that if the count hasn't changed, then only look in the second level cache and don't bother hitting the database even though it is a cache miss.

Thoughts?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.