要引入

import org.hibernate.annotations.Cache;

在类前面添加:

@Cache(usage= CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)

可选项有:

  • read-only

  • read-write

  • nonstrict-read-write

  • transactional

完整示例:

package com.hlcg.main.bean;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy; import javax.persistence.*; /**
* Created with IntelliJ IDEA.
* User: HYY
* Date: 13-10-20
* Time: 下午1:04
* To change this template use File | Settings | File Templates.
*/
@Entity
@Table(name = "hl_key_value")
@Cache(usage= CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class KeyValue {
private Integer id;//主键
private String key;
private String value;
private Integer type;//类型
private String description;//描述、简介 @Id
@SequenceGenerator(name = "increment")
@GeneratedValue(strategy = GenerationType.AUTO, generator = "increment")
public Integer getId() {
return id;
} public void setId(Integer id) {
this.id = id;
} @Column(name = "`key`", unique = true,nullable=false, length = 200)
public String getKey() {
return key;
} public void setKey(String key) {
this.key = key;
} @Column(name = "`value`", length = 3000)
public String getValue() {
return value;
} public void setValue(String value) {
this.value = value;
} @Column(name = "`type`")
public Integer getType() {
return type;
} public void setType(Integer type) {
this.type = type;
} @Column(length = 300)
public String getDescription() {
return description;
} public void setDescription(String description) {
this.description = description;
}
}

注意key,value都是数据库的关键字 要加上``才行。

最新文章

  1. s2sh框架搭建(辅助工具:MyEclipse)及解决一些遇到的问题
  2. Code笔记之:CSS块级元素、内联元素概念
  3. 密码学初级教程(一)基本概念及DES加密算法
  4. Maven学习(三) -- 仓库
  5. cmd 打开gitshell
  6. html制作,点击文字超链接显示文本框,再点击文字超链接隐藏文本框
  7. oj 中G++和C++区别(转)
  8. java 反编译插件 JD-Eclipse 和 JD-IntelliJ
  9. 函数innobase_start_or_create_for_mysql
  10. node.js(七) 子进程 child_process模块
  11. 星环大数据安全组件Guardian与hadoop自带的安全组件区别
  12. (转)linux进程 linux线程 信息查看 ps top pstree
  13. SDN第三次上机
  14. Linux基础命令---bunzip2
  15. #001 Emmet的API图片
  16. mysql命令gruop by报错this is incompatible with sql_mode=only_full_group_by
  17. TextureMerger1.6.6 一:Egret MovieClip的制作和使用
  18. delphi IOS BLE 代理
  19. DHCP协议及基本实现原理
  20. Java——异常博客作业

热门文章

  1. SourceTree - 好用的 Git / Mercurial GUI 管理工具 for Mac OS X
  2. GUI编程笔记(java)02:java.awt和java.swing包的区别
  3. WebView实现文件下载功能
  4. runtime重写description方法打印model属性和值
  5. Mybatis高级应用
  6. .net单元测试——常用测试方式(异常模拟、返回值测试、参数测试、数据库访问代码测试)
  7. 如何:确定调用 ASP.NET 网页的方式
  8. js跨浏览器事件对象、事件处理程序
  9. windows 2003 搭建一个vpn
  10. Mybatis的学习总结二:使用Mybatis对表进行CRUD操作【参考】