比如用jbosscache做二级缓存,如何才能看到二级缓存里的东东?
[b]问题补充:[/b]
还是不知道hibernate的二级缓存如何能得到,比如通过lookup之类。
直接get的话前提是取得cache,现在甚至连hibernate创建cacheService的配置是怎样都不清楚,更不知道按什么key来保存了
[b]问题补充:[/b]
啊,我用的是jbosscache1.4.。。。。。
我记得jboss的wiki上推荐hibernate3.3以后的版本使用jbosscache2-3
hibernate3.2用1.4
我是参考http://www.jboss.org/community/docs/DOC-12948做的
所以木有这个类,用TreeCache也不成
[b]问题补充:[/b]
public TreeCache(org.jboss.cache.TreeCache cache, String regionName...
构造函数的cache参数是我所得不到的。
我问题的关键也就是取得这个cache,而不是创建个新的
我有空查下源码ba,3q。
如果为hibernate配置了二级缓存,如何查看缓存内容?
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
3条回答
- my_asker 2009-02-10 21:47关注
[code="java"].
.
package org.hibernate.cache;
.
/**- Represents a particular region within the given JBossCache TreeCache. *
- @author Gavin King */ public class TreeCache implements Cache, TransactionAwareCache { . private static final String ITEM = "item"; . public TreeCache(org.jboss.cache.TreeCache cache, String regionName, TransactionManager transactionManager) throws CacheException { this.cache = cache; this.regionName = regionName; this.regionFqn = Fqn.fromString( regionName.replace( '.', '/' ) ); this.transactionManager = transactionManager; } . public Object read(Object key) throws CacheException { try { return cache.get( new Fqn( regionFqn, key ), ITEM ); } catch (Exception e) { throw new CacheException(e); } } . public void put(Object key, Object value) throws CacheException { Transaction tx = suspend(); try { //do the failfast put outside the scope of the JTA txn cache.putFailFast( new Fqn( regionFqn, key ), ITEM, value, 0 ); } catch (TimeoutException te) { //ignore! log.debug("ignoring write lock acquisition failure"); } catch (Exception e) { throw new CacheException(e); } finally { resume( tx ); } } . } . .[/code]
以上是hibernate的源码。
Fqn: regionName.replace( '.', '/' )
key: ITEM = "item";
不用我多说了吧。本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥100 求数学坐标画圆以及直线的算法
- ¥100 c语言,请帮蒟蒻写一个题的范例作参考
- ¥15 名为“Product”的列已属于此 DataTable
- ¥15 安卓adb backup备份应用数据失败
- ¥15 eclipse运行项目时遇到的问题
- ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
- ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
- ¥15 自己瞎改改,结果现在又运行不了了
- ¥15 链式存储应该如何解决
- ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站