Closed GoogleCodeExporter closed 9 years ago
I think you need to set the cacheRegion.
setCacheRegionName(blah)
Original comment by raykrue...@gmail.com
on 27 Jun 2010 at 4:59
but i see log at application start:
INFO : com.googlecode.hibernate.memcached.MemcachedCacheProvider - Building
cache for region [com.zwc.datasystem.entity.sys.Menu]
DEBUG: com.googlecode.hibernate.memcached.MemcachedCacheProvider - Using
KeyStrategy: [com.googlecode.hibernate.memcached.HashCodeKeyStrategy]
INFO : com.googlecode.hibernate.memcached.MemcachedCacheProvider - Building
cache for region [com.zwc.datasystem.entity.sys.Auth]
DEBUG: com.googlecode.hibernate.memcached.MemcachedCacheProvider - Using
KeyStrategy: [com.googlecode.hibernate.memcached.HashCodeKeyStrategy]
INFO : com.googlecode.hibernate.memcached.MemcachedCacheProvider - Building
cache for region [com.zwc.datasystem.entity.manage.StatBet]
DEBUG: com.googlecode.hibernate.memcached.MemcachedCacheProvider - Using
KeyStrategy: [com.googlecode.hibernate.memcached.HashCodeKeyStrategy]
INFO : com.googlecode.hibernate.memcached.MemcachedCacheProvider - Building
cache for region [com.zwc.datasystem.entity.manage.StatDetailReport]
DEBUG: com.googlecode.hibernate.memcached.MemcachedCacheProvider - Using
KeyStrategy: [com.googlecode.hibernate.memcached.HashCodeKeyStrategy]
INFO : com.googlecode.hibernate.memcached.MemcachedCacheProvider - Building
cache for region [com.zwc.datasystem.entity.sys.User]
DEBUG: com.googlecode.hibernate.memcached.MemcachedCacheProvider - Using
KeyStrategy: [com.googlecode.hibernate.memcached.HashCodeKeyStrategy]
INFO : com.googlecode.hibernate.memcached.MemcachedCacheProvider - Building
cache for region [com.zwc.datasystem.entity.sys.Resource]
DEBUG: com.googlecode.hibernate.memcached.MemcachedCacheProvider - Using
KeyStrategy: [com.googlecode.hibernate.memcached.HashCodeKeyStrategy]
INFO : com.googlecode.hibernate.memcached.MemcachedCacheProvider - Building
cache for region [com.zwc.datasystem.entity.sys.Module]
DEBUG: com.googlecode.hibernate.memcached.MemcachedCacheProvider - Using
KeyStrategy: [com.googlecode.hibernate.memcached.HashCodeKeyStrategy]
INFO : com.googlecode.hibernate.memcached.MemcachedCacheProvider - Building
cache for region [com.zwc.datasystem.entity.sys.Role]
like auto add the cacheRegion?
Original comment by Tuzl...@gmail.com
on 27 Jun 2010 at 5:07
Those are the region names for your entities. Your queries need a region name
as well.
Original comment by raykrue...@gmail.com
on 27 Jun 2010 at 5:09
when query cacheRegion is empty ,why not auto add the cacheRegion for query?:)
Original comment by Tuzl...@gmail.com
on 27 Jun 2010 at 5:13
Thanks raykrueger, but when i use hibernate query , i try use
query.setCacheRegion(entityClass.getName());
but still have this problem , duplicate hashcode
Original comment by Tuzl...@gmail.com
on 27 Jun 2010 at 5:34
I see the hibernate-memcached-1.2.2.jar code:
public class HashCodeKeyStrategy extends AbstractKeyStrategy
{
protected String transformKeyObject(Object key)
{
int hashCode = key.hashCode();
this.log.debug("Transformed key [{}] to hashCode [{}]", key, Integer.valueOf(hashCode));
return String.valueOf(hashCode);
}
}
and i see the debug log:
DEBUG: com.googlecode.hibernate.memcached.HashCodeKeyStrategy - Transformed key
[sql: select menu4_.id as id5_, menu4_.create_time as create2_5_, menu4_.is_dir
as is3_5_, menu4_.last_modify_time as last4_5_, menu4_.module_id as module5_5_,
menu4_.name as name5_, menu4_.parent_id as parent7_5_, menu4_.sort_index as
sort8_5_, menu4_.url as url5_ from user user0_, role role1_, auth auth2_,
resource resource3_, menu menu4_ where user0_.id=? and user0_.role_id=role1_.id
and role1_.id=auth2_.role_id and auth2_.resource_id=resource3_.id and
resource3_.rtype=? and resource3_.object_id=menu4_.id and menu4_.parent_id=?
and menu4_.module_id=?; parameters: ; named parameters: {parentId=0,
moduleId=2, userId=1, rtype=2}] to hashCode [2082154712]
i try:
this.log.debug("Transformed key [{}] to hashCode [{}]", key,
Integer.valueOf(hashCode));
1.I copy log key for first param:
sql: select menu4_.id as id5_, menu4_.create_time as create2_5_, menu4_.is_dir
as is3_5_, menu4_.last_modify_time as last4_5_, menu4_.module_id as module5_5_,
menu4_.name as name5_, menu4_.parent_id as parent7_5_, menu4_.sort_index as
sort8_5_, menu4_.url as url5_ from user user0_, role role1_, auth auth2_,
resource resource3_, menu menu4_ where user0_.id=? and user0_.role_id=role1_.id
and role1_.id=auth2_.role_id and auth2_.resource_id=resource3_.id and
resource3_.rtype=? and resource3_.object_id=menu4_.id and menu4_.parent_id=?
and menu4_.module_id=?; parameters: ; named parameters: {parentId=0,
moduleId=2, userId=1, rtype=2}
2. i try
System.out.println(String.valueOf(key.hashCode)) this output is: -177187100
not equals log output : 2082154712
Original comment by Tuzl...@gmail.com
on 27 Jun 2010 at 5:44
what's the (protected String transformKeyObject(Object key)) key type ?
Original comment by Tuzl...@gmail.com
on 27 Jun 2010 at 5:46
I have to sleep , soo tired for this probleam, if any one have suggestion mail
me:
tuhaitao@foxmail.com
thanks.
Original comment by Tuzl...@gmail.com
on 27 Jun 2010 at 5:50
Every query needs to have it's own individual cache region name. I can't just
make one up, and you shouldn't use the entity name. Each hql you write should
have it's own region name.
Original comment by raykrue...@gmail.com
on 27 Jun 2010 at 6:46
In that case...
Closing this as it's not a bug. Bring up the discussion on the list if you'd
like to talk about it further.
Original comment by raykrue...@gmail.com
on 27 Jun 2010 at 7:16
Original issue reported on code.google.com by
Tuzl...@gmail.com
on 27 Jun 2010 at 4:52