【发布时间】:2017-10-24 20:14:12
【问题描述】:
到目前为止,在 Hibernate OGM 的所有文档中,我从未见过任何使用 Spring 的 Java @Configuration 进行设置的示例。文档和示例项目中的所有示例都使用 persistence.xml 来配置持久性单元。
Java config 不能用于实现 Hibernate OGM Persistence 设置是否有任何原因/限制?
理想情况下,我想将下面的 persistence.xml 转换为 java 配置:
<!-- Use the Hibernate OGM provider: configuration will be transparent -->
<provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider>
<properties>
<!-- Here you will pick which NoSQL technology to use, and configure it;
in this example we start a local in-memory redis_experimental node. -->
<property name="hibernate.ogm.datastore.provider" value="redis_experimental"/>
<property name="hibernate.ogm.datastore.host" value="127.0.0.1:6379"/>
<property name="hibernate.cache.use_second_level_cache" value="true"/>
<property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.redis.hibernate5.SingletonRedisRegionFactory"/>
<property name="hibernate.cache.region_prefix" value="hibernate"/>
<property name="hibernate.cache.use_query_cache" value="true"/>
<property name="hibernate.cache.provider_configuration_file_resource_path" value="hibernate-redis.properties"/>
</properties>
</persistence-unit>
【问题讨论】:
-
你是说Spring的
@Configuration注解吗? -
确实,我只是习惯称它为 java config。感谢您指出这一点
-
应该和配置非OGM持久化单元没有太大区别,见stackoverflow.com/questions/1989672/…
标签: spring jpa spring-data-jpa hibernate-ogm