I am having some problems with ehcache in distributed mode and queries. I have a simple spring+hibernate+ehcache webapp running on two tomcat servers. I have enabled second level caching and I can see my simple pojo gets replicated back and forth fine between the two servers.
The query caching seems to work fine if I have a single server started. I can see that is using the cached query and not hitting the db. However what I am trying to test is if I have two boxes - box1 does query and populates cache which gets replicated to box2 - then box2 doesn't need to do query since its in cache.
My problem is that the query from box1 is not recognized as being the same as on box2 - it seems to get cached multiple times. Below is a log snippet of the two objects which are in my query cache - there should only be one. The first debug line is showing a query object which was replicated over from another box - the second line is showing a query object which was populated locally. This should not happen since they are the same query.
21:03:39,763 DEBUG net.sf.ehcache.store.MemoryStore - findTopXCache: findTopXMemoryStore hit for sql: select this_.emp_id as emp1_2_0_, this_.emp_firstname as emp2_2_0_, this_.emp_surname as emp3_2_0_ from Employee this_; parameters: ; first row: 0; max rows: 10; transformer: org.hibernate.transform.RootEntityResultTransformer@a725aa
LOCAL: [ key = sql: select this_.emp_id as emp1_2_0_, this_.emp_firstname as emp2_2_0_, this_.emp_surname as emp3_2_0_ from Employee this_; parameters: ; first row: 0; max rows: 10; transformer: org.hibernate.transform.RootEntityResultTransformer@a725aa, value=[4968486262001664, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], version=1, hitCount=0, CreationTime = 1213009341528, LastAccessTime = 0 ]
21:03:39,763 DEBUG net.sf.ehcache.store.MemoryStore - findTopXCache: findTopXMemoryStore hit for sql: select this_.emp_id as emp1_2_0_, this_.emp_firstname as emp2_2_0_, this_.emp_surname as emp3_2_0_ from Employee this_; parameters: ; first row: 0; max rows: 10; transformer: org.hibernate.transform.RootEntityResultTransformer@aa11a6
LOCAL: [ key = sql: select this_.emp_id as emp1_2_0_, this_.emp_firstname as emp2_2_0_, this_.emp_surname as emp3_2_0_ from Employee this_; parameters: ; first row: 0; max rows: 10; transformer: org.hibernate.transform.RootEntityResultTransformer@aa11a6, value=[4968486194896896, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], version=1, hitCount=5, CreationTime = 1213009325003, LastAccessTime = 1213009415332 ]
Does anybody have any ideas?
|