比如用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";
不用我多说了吧。本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
- ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
- ¥15 绘制多分类任务的roc曲线时只画出了一类的roc,其它的auc显示为nan
- ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
- ¥20 腾讯企业邮箱邮件可以恢复么
- ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
- ¥15 错误 LNK2001 无法解析的外部符号
- ¥50 安装pyaudiokits失败
- ¥15 计组这些题应该咋做呀
- ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?