×

hibernate二级缓存 hibernate ate

配置hibernate二级缓存,有几种方法?sql中不支持create table as 表名 select 语法

admin admin 发表于2022-07-07 14:24:53 浏览105 评论0

抢沙发发表评论

配置hibernate二级缓存,有几种方法


19.2.1. 缓存映射(Cache mappings)
类或者集合映射的“《cache》元素”可以有下列形式:

《cache
usage=“transactional|read-write|nonstrict-read-write|read-only“
region=“RegionName“
include=“all|non-lazy“
/》 usage(必须)说明了缓存的策略: transactional、 read-write、 nonstrict-read-write或 read-only。

region (可选, 默认为类或者集合的名字(class or collection role name)) 指定第二级缓存的区域名(name of the second level cache region)

include (可选,默认为 all) non-lazy 当属性级延迟抓取打开时, 标记为lazy=“true“的实体的属性可能无法被缓存

另外(首选?), 你可以在hibernate.cfg.xml中指定《class-cache》和 《collection-cache》 元素。

这里的usage 属性指明了缓存并发策略(cache concurrency strategy)。

19.2.2. 策略:只读缓存(Strategy: read only)
如果你的应用程序只需读取一个持久化类的实例,而无需对其修改, 那么就可以对其进行只读 缓存。这是最简单,也是实用性最好的方法。甚至在集群中,它也能完美地运作。

《class name=“eg.Immutable“ mutable=“false“》
《cache usage=“read-only“/》
....
《/class》19.2.3. 策略:读/写缓存(Strategy: read/write)
如果应用程序需要更新数据,那么使用读/写缓存 比较合适。 如果应用程序要求“序列化事务”的隔离级别(serializable transaction isolation level),那么就决不能使用这种缓存策略。 如果在JTA环境中使用缓存,你必须指定hibernate.transaction.manager_lookup_class属性的值, 通过它,Hibernate才能知道该应用程序中JTA的TransactionManager的具体策略。 在其它环境中,你必须保证在Session.close()、或Session.disconnect()调用前, 整个事务已经结束。 如果你想在集群环境中使用此策略,你必须保证底层的缓存实现支持锁定(locking)。Hibernate内置的缓存策略并不支持锁定功能。

《class name=“eg.Cat“ .... 》
《cache usage=“read-write“/》
....
《set name=“kittens“ ... 》
《cache usage=“read-write“/》
....
《/set》
《/class》

sql中不支持create table as 表名 select 语法


你说的似乎在MSSQL中不支持,但是对于一张已经存在的表,如果你要把另外一张表的数据导入,请务必这样处理: 1)使用SQL创建一张表。2)然后insert into 创建的新表 select * from 旧表。 旧表必须和新表结构一摸一样。

garnish与decorate的区别是


ornament是名词,装饰品;decorate是偏向于装潢的意思;deck多用于被动语态,decked
with(in)sth,指被装饰;garnish多指对餐桌上的食物进行点缀,一般搭配with,如fish
garnished
with
slices
of
lemon;embellish则是指装饰和美化某物,如衣服,艺术品等,也可搭配with,如a
dress
embellished
with
lace

-hibernate