博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Hibernate中配置二级缓存的并发策略
阅读量:4177 次
发布时间:2019-05-26

本文共 653 字,大约阅读时间需要 2 分钟。

Hibernate应用中,设置二级缓存的并发策略有两种方法,一种是通过Hibernate的全局配置文件,另一种是为各个Entity类单独设置。

1. 通过hibernate.cache.default_cache_concurrency_strategy配置参数,设置全局的二级缓存的并发策略

hibernate.cache.default_cache_concurrency_strategy配置参数的可用值:

  • read-only,适合只读事务
  • read-write,适合读写事务
  • nonstrict-read-write,适合高并发的读写事务
  • transactional,事务序列化

2. 使用Cache标注为各个Entity类单独设置二级缓存的并发策略

  • @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
  • @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
  • @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
  • @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)

转载地址:http://dslai.baihongyu.com/

你可能感兴趣的文章
webpack教程
查看>>
安装composer时出现 failed to open stream: HTTP request failed!的错误
查看>>
禁用HBuilderX自动更新
查看>>
C++字符串函数
查看>>
mknod详解
查看>>
linux中的run-level何解?
查看>>
Linux内核编译详解(转自linuxSir)
查看>>
实模式,保护模式与V86模式
查看>>
628. Maximum Product of Three Numbers(排序)
查看>>
Linux内核-------同步机制(一)
查看>>
485. Max Consecutive Ones(数组)
查看>>
287. Find the Duplicate Number(数组)
查看>>
Linux内核-------同步机制(二)
查看>>
面试题31-------连续子数组的最大和(数组)
查看>>
epoll 实现Chat
查看>>
21. Merge Two Sorted Lists(链表)
查看>>
2. Add Two Numbers(链表)
查看>>
637. Average of Levels in Binary Tree(Tree)
查看>>
226. Invert Binary Tree(Tree)
查看>>
328. Odd Even Linked List(链表)
查看>>