hibernate4 二级缓存demo实例
来源:互联网 发布:c语言电影院售票系统 编辑:程序博客网 时间:2024/05/22 10:25
Hibernate4 所需jar
导入/lib/required文件夹下的所有jar包
配置连接池需要导入/lib/optional/c3p0文件夹中的所有jar包
数据库使用的是MYSQL,因此还需要mysql的连接驱动:mysql-connector-java-5.1.22-bin.jar
hibernate.cfg.xml<?xml version='1.0' encoding='utf-8'?> <!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> <!-- Database connection settings --> <property name="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="connection.url">jdbc:mysql://127.0.0.1:3306/hibernate4</property> <property name="connection.username">root</property> <property name="connection.password">root</property> <!--配置c3p0连接池--><!-- Enable c3p0 connection pooling,beacause hibernate pooling is not prod-ready. Apparently connection.provider_class is needed in hibernate 3+ --> <!-- <property name="connection.provider_class">org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider</property> --> <property name="hibernate.c3p0.min_size">1</property> <property name="hibernate.c3p0.max_size">100</property> <property name="hibernate.c3p0.idle_test_period">30</property>
<!-- JDBC connection pool (use the built-in) --> <property name="connection.pool_size">1</property> <!-- SQL dialect --> <property name="dialect">org.hibernate.dialect.MySQL5Dialect</property> <!-- Enable Hibernate's automatic session context management --> <property name="current_session_context_class">thread</property> <!-- Disable the second-level cache --> <!--<property name="cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property> --> <!-- 配置二级缓存 --> <property name="hibernate.cache.use_second_level_cache">true</property> <property name="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</property> <!-- hibernate3的二级缓存配置 --> <!-- <property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property> --> <!-- 开启查询缓存 --> <property name="hibernate.cache.use_query_cache">true</property> <!-- Echo all executed SQL to stdout --> <property name="show_sql">true</property> <!-- Drop and re-create the database schema on startup --> <property name="hbm2ddl.auto">update</property> <mapping class="com.test.pojo.User" /> </session-factory> </hibernate-configuration>
注意:hibernate4和hibernate3配置不一样,hibernate4是<property name="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</property>而hibernate3的配置是<property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
0 0
- hibernate4 二级缓存demo实例
- hibernate4 二级缓存demo实例
- hibernate4 二级缓存demo实例
- hibernate4 二级缓存demo实例
- hibernate4 二级缓存demo实例
- hibernate4 二级缓存demo实例 ( hibernate3 的不同之处)
- hibernate4二级缓存
- Hibernate4之二级缓存配置
- Hibernate4.1.2 二级缓存问题
- Hibernate4二级缓存配置
- Hibernate4之二级缓存配置
- Hibernate4之二级缓存配置
- Hibernate4之二级缓存配置
- Spring整合Hibernate4二级缓存
- Hibernate4之二级缓存配置
- Hibernate4之二级缓存配置
- hibernate4之二级缓存
- Hibernate4之二级缓存配置
- Codeforces Round #243 (Div. 2)总结
- Qt保存 XML
- 中移动送4G流量
- MySQL查询数据库表单的大小
- [AIR接入Android 平台]处理res资源之文字国际化
- hibernate4 二级缓存demo实例
- QQ单点登陆 在HTC手机上不能使用问题的解决
- 通用能源管理平板展示系统程序文档说明
- android设计模式之里氏代换原则(LSP)
- Mac操作积累的一些技巧-陆续增加中
- [转]JMS与MQ详解
- MFC界面之通过软件制作图像序列
- MySql添加注释
- ASP+与ASP有哪些区别