LocalContainerEntityManagerFactoryBean компонент конфигурации гибернации инициализируется в цикле - PullRequest
0 голосов
/ 30 сентября 2019

Моя фабрика диспетчера сущностей hibernate объявлена ​​в jpa.xml, hazecast настроен в hazelcast.xml, и у меня настроена модель домена, и у меня есть соответствующий componentContext.xml, присутствующий в проекте модели домена, где реализован мой класс фабрики диспетчера сущностей. Это. Но проблема, с которой я сталкиваюсь, заключается в том, что мой bean-компонент в componentContext.xml инициализируется в цикле (наблюдается из hibernate.log)

В моем Web.xml настроен только com.sun.faces.config.ConfigureListener listenere. .

My Stack Spring - 4.3.8 Hibernate - 5.0.10-FINAL hazelcast-hibernate5 - 1.3.0

JPA.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
  xsi:schemaLocation="http://www.springframework.org/schema/beans 
                           http://www.springframework.org/schema/beans/spring-beans.xsd 
                           http://www.springframework.org/schema/context 
                           http://www.springframework.org/schema/context/spring-context.xsd">

  <context:property-placeholder location="classpath:dataSources.properties" />

  <!-- Default JPA configuration for OpenJPA and Hibernate -->


  <!-- Hibernate configuration -->
  <bean id="hibernateEntityManagerFactory" abstract="true" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="jpaPropertyMap">
      <map>
        <entry key="hibernate.max_fetch_depth" value="3" />
        <entry key="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider" />
        <entry key="hibernate.enable_lazy_load_no_trans" value="true" />
        <entry key="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform" />
        <entry key="hibernate.current_session_context_class" value="jta" />

      </map>
    </property>
    <property name="jpaVendorAdapter">
      <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
        <property name="database" value="${dbDialect}" />
      </bean>
    </property>
  </bean>

  <alias name="hibernateEntityManagerFactory" alias="entityManagerFactory" />

</beans>

componentContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:cache="http://www.springframework.org/schema/cache" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:context="http://www.springframework.org/schema/context"
  xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd"
  xmlns:jpa="http://www.springframework.org/schema/data/jpa">

  <context:component-scan base-package="com.volvo.myfirstdomain.base />
  <context:annotation-config />

  <!-- JPA EntityManagerFactory -->
  <!-- Based on choice of implementation between OpenJPA and Hibernate, parent attribute in bean should be set. For OpenJPA: parent = "openJpaEntityManagerFactory" 
    For Hibernate: parent = "hibernateEntityManagerFactory" Here, OpenJPA is chosen as you can see below. -->
  <bean id="myDomainEntityManagerFactory" parent="entityManagerFactory">
    <property name="persistenceUnitName" value="MYDomainPU" />
    <property name="packagesToScan" value="com.volvo.myfirstdomain.entity" />

    <property name="jpaProperties">
      <props>
        <prop key="hibernate.default_schema">DOMAIN_ONE</prop>
        <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect </prop>
        <prop key="hibernate.cache.region.factory_class">com.hazelcast.hibernate.HazelcastCacheRegionFactory</prop>
        <prop key="hibernate.cache.use_second_level_cache">true</prop>
        <prop key="hibernate.cache.use_query_cache">true</prop>
        <prop key="javax.persistence.sharedCache.mode">ENABLE_SELECTIVE</prop>

      </props>
    </property>

  </bean>

  <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
    <constructor-arg ref="dataSource" />
  </bean>
</beans>

Я пытался отладить несколько раз, но я не могу понять, почему инициализация происходит несколько раз (как в цикле). Любые указатели очень ценятся!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...