debop / hibernate-redis

hibernate 2nd level cache privder using redis
Apache License 2.0
358 stars 182 forks source link

Load the JpaProperties as the default value for hibernate-redis confi… #48

Closed wangjingfei closed 8 years ago

wangjingfei commented 8 years ago

By default, hibernate-redis only loads properties from hibernate-redis.properties. But sometimes we want to reuse the configuration from other configurations.

e.g. I'd like to reuse the following configurations:

    <bean id="entityManager" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="packagesToScan">
            <list>
                <value>cn.irenshi.meta.dto.*.mysql</value>
            </list>
        </property>
        <property name="jpaVendorAdapter" ref="jpaVendorAdapter"/>
        <property name="jpaProperties">
            <props>
                <prop key="connection.autoReconnect">true</prop>
                <prop key="connection.autoReconnectForPools">true</prop>
                <prop key="connection.is-connection-validation-required">true</prop>
                <prop key="hibernate.hbm2ddl.auto">${datasource.hibernate.hbm2ddl.auto:update}</prop>
                <prop key="hibernate.dialect">${datasource.hibernate.dialect:org.hibernate.dialect.MySQL5InnoDBDialect}</prop>

                <!-- Redis cache for hibernate -->
                <prop key="hibernate.cache.use_second_level_cache">true</prop>
                <prop key="hibernate.cache.use_query_cache">true</prop>
                <prop key="hibernate.cache.region.factory_class">org.hibernate.cache.redis.SingletonRedisRegionFactory</prop>
                <prop key="hibernate.cache.region_prefix">hibernate</prop>
                <prop key="redis.host">${redis.address}</prop>
                <prop key="redis.port">${redis.port:6379}</prop>
                <prop key="redis.password">${redis.auth:somepass}</prop>
                <prop key="hibernate.cache.use_structured_entries">true</prop>
            </props>
        </property>
    </bean>
jonspalmer commented 8 years ago

I'm pretty sure this is solved by

I'm pretty sure this is fixed by changes as part of this PR: https://github.com/hibernate-redis/hibernate-redis/pull/3

Note that we are now maintaining an active fork an publishing releases from here: https://github.com/hibernate-redis/hibernate-redis

wangjingfei commented 8 years ago

Thanks @bostanio, I'll check the forked one.