hibernate 3.3采纳新的缓存办法[Java编程]
本文“hibernate 3.3采纳新的缓存办法[Java编程]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:
本日查看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 libraries). {@link org.hibernate.cache.RegionFactory} also defines how to build specialized {@link org.hibernate.cache.Region} instances based on the type of data we will be storing in that given region. The fact that {@link org.hibernate.cache.RegionFactory} is asked to build specialized regions (as opposed to just general access) is the first improvement over the legacy scheme. The second improvement is the fact that the regions (well the ones like entity and collection regions that are responsible for storing {@link org.hibernate.cache.TransactionalDataRegion transactional} data) are asked to build their own access strategies (see {@link org.hibernate.cache.EntityRegion#buildAccessStrategy} and {@link org.hibernate.cache.CollectionRegion#buildAccessStrategy}).
以上是“hibernate 3.3采纳新的缓存办法[Java编程]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
本文地址: | 与您的QQ/BBS好友分享! |