快速业务通道

hibernate 3.3采用新的缓存方法 - 编程入门网

作者 佚名技术 来源 NET编程 浏览 发布时间 2012-06-20

hibernate 3.3采用新的缓存方法

时间:2011-01-19 javaeye xly_971223

今天查看hibernate cache接口时 svn了hibernate3.3的源码

打开CacheProvider类一看 居然给 @deprecated

真是大块人心

早就对hibernate的二级缓存和查询缓存不爽

只能按照实体配置 不能针对某条查询语句设置

3.3的提供了两个接口 Region  RegionFactory 来代替 3.2中的Cache CacheProvider

看看RegionFactory 的实现吧

看看这几个方法名字是多么的让人激动

Java代码

buildCollectionRegion 对集合的缓存 猜测是对一对多的集合进行配置的吧 buildQueryResultsRegion 查询缓存 自定义的查询 也可以有自己的region了 buildTimestampsRegion  给缓存设置过期时间吧

英文不好 猜测的 英文好的可以翻译一下

在gg上搜索了一下hibernate RegionFactory 关键字 居然没搜索到

难道大家对个功能都不感冒

Java代码

public interface RegionFactory {   public void start(Settings settings, Properties properties) throws CacheException;   public void stop();   public boolean isMinimalPutsEnabledByDefault();   public long nextTimestamp();   public EntityRegion buildEntityRegion(String regionName, Properties properties, CacheDataDescription metadata) throws CacheException;   public CollectionRegion buildCollectionRegion(String regionName, Properties properties, CacheDataDescription metadata) throws CacheException;   public QueryResultsRegion buildQueryResultsRegion(String regionName, Properties properties) throws CacheException;   public TimestampsRegion buildTimestampsRegion(String regionName, Properties properties) throws CacheException; }

附上hibernate3.3 cache包里的说明

引用

This package defines APIs/SPIs and implementations for the Hibernate second-level cache.

The legacy (and now deprecated) approach to caching is defined by the {@link org.hibernate.cache.CacheProvider} and {@link org.hibernate.cache.Cache} interfaces as well as the {@link org.hibernate.cache.CacheConcurrencyStrategy} interface along with the various implementations of all these interfaces. In that scheme, a {@link org.hibernate.cache.CacheProvider} defined how to configure and perform lifecycle operations in regards to a particular underlying caching library; it also defined how to build {@link org.hibernate.cache.Cache} instances which in turn defined how to access the "regions" of the underlying cache instance. For entity and collection data cache regions, {@link org.hibernate.cache.CacheConcurrencyStrategy} wrapped access to those cache regions to apply transactional/concurrent access semantics.

The improved approach is based on {@link org.hibernate.cache.RegionFactory}, the various {@link org.hibernate.cache.Region} specializations and the two access strategies contracts ({@link org.hibernate.cache.access.EntityRegionAccessStrategy} and {@link org.hibernate.cache.access.CollectionRegionAccessStrategy}). The general approach here is that {@link org.hibernate.cache.RegionFactory} defined how to configure and perform lifecycle operations in regards to a particular underlying caching library (or

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号