文章标题
2015-07-15 20:28
363 查看
## Hibernate 二级缓存配置中的问题##
hibernate配置完二级缓存之后会报错:
org.xml.sax.SAXParseException: The content of element type “session-factory” must match “(property*,mapping*,(class-cache|collection-cache),event,listener*)”.
Hibernate.cfg.xml文件的配置方法如下:
从网上找到相关答案(http://bbs.csdn.net/topics/330186432),是因为User的缓存配置有问题,应该将下面两段代码交换位置就可以
hibernate配置完二级缓存之后会报错:
org.xml.sax.SAXParseException: The content of element type “session-factory” must match “(property*,mapping*,(class-cache|collection-cache),event,listener*)”.
Hibernate.cfg.xml文件的配置方法如下:
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory name="foo" > <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/lbxtest</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.connection.password">admin</property> <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> <property name="hibernate.show_sql">true</property> <property name="hibernate.hbm2ddl.auto">create-drop</property> <!-- 是否使用二级缓存,默认为使用 --> <property name="hibernate.cache.use_second_level_cache">true</property> <!-- 缓存类型 --> <property name="hibernate.cache.provider_class">org.hibernate.cache.OSCacheProvider</property> <!-- 指定需要缓存的类 ,还可以在配置文件*.hbm.xml中设置--> <class-cache usage="read-write" class="cn.lbx.hibernate.domain.User"/> <mapping resource="cn/lbx/hibernate/domain/User.hbm.xml"/> </session-factory> </hibernate-configuration>
从网上找到相关答案(http://bbs.csdn.net/topics/330186432),是因为User的缓存配置有问题,应该将下面两段代码交换位置就可以
<class-cache usage="read-write" class="cn.lbx.hibernate.domain.User"/>
<mapping resource="cn/lbx/hibernate/domain/User.hbm.xml"/> </session-factory>
相关文章推荐
- HDU 1233
- poj 3140
- 【leetcode】26. Remove Duplicates from Sorted Array
- leetcode--twoSum
- 使用itms-services安装ipa
- hdu 1069 最长上升子序列变形
- Codeforces 164 E Compatible Numbers
- 产生不大于100的随机正整数,用户通过键盘对随机正整数进行猜测,猜大了给用户提示猜大,猜小提示猜小, 猜对了则提示“恭喜,猜对了”,结束游戏。
- 产生不大于100的随机正整数,用户通过键盘对随机正整数进行猜测,猜大了给用户提示猜大,猜小提示猜小, 猜对了则提示“恭喜,猜对了”,结束游戏。
- SQL中CONVERT转化函数的用法
- QQ游戏百万人同时在线服务器架构实现
- PHP + Memcache 实现多服务器session共享 (补充)
- POJ 1258
- CentOS 安装 Maven
- WPF 画线动画效果实现
- JAVA基本语法--java的数据类型
- 插值器 animation动画
- 【西祠日志】【01】第一天工作,我想,这是一个新的开始
- 跳槽
- FAST特征点检测算法