1.4K Star 5.1K Fork 1.8K

GVP红薯/J2Cache

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

Hibernate 5 支持模块

基于 Hibernate 5.2.17 开发,感谢 @tandy

Maven:

<dependency>
  <groupId>net.oschina.j2cache</groupId>
  <artifactId>j2cache-hibernate5</artifactId>
  <version>1.0.0-beta1</version>
</dependency>

使用说明:

1、XML文件配置

    <bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
        <property name="hibernateProperties">
            <props>
                ...省略其他配置...
                <prop key="hibernate.current_session_context_class">org.springframework.orm.hibernate5.SpringSessionContext</prop>
                <prop key="hibernate.cache.region.factory_class">net.oschina.j2cache.hibernate5.J2CacheRegionFactory</prop>
                <prop key="hibernate.cache.use_second_level_cache">true</prop>
                <prop key="hibernate.cache.use_query_cache">true</prop>
            </props>
        </property>
        ...省略其他配置...
    </bean>

2、properties文件配置

    spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate5.SpringSessionContext
    spring.jpa.properties.hibernate.cache.region.factory_class=net.oschina.j2cache.hibernate5.J2CacheRegionFactory
    spring.jpa.properties.hibernate.cache.use_second_level_cache=true
    spring.jpa.properties.hibernate.cache.use_query_cache=true

3、yml文件配置

    spring:
        jpa:
            properties:
                hibernate:
                    current_session_context_class: org.springframework.orm.hibernate5.SpringSessionContext
                    cache:
                        use_second_level_cache: true
                        use_query_cache: true
                        region:
                            factory_class: net.oschina.j2cache.hibernate5.J2CacheRegionFactory
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/ld/J2Cache.git
git@gitee.com:ld/J2Cache.git
ld
J2Cache
J2Cache
master

搜索帮助