比如用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 如何用脚本实现输入法的热键设置
- ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
- ¥30 深度学习,前后端连接
- ¥15 孟德尔随机化结果不一致
- ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
- ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
- ¥15 谁有desed数据集呀
- ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
- ¥15 关于#hadoop#的问题
- ¥15 (标签-Python|关键词-socket)