IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Spring Java Discussion :

Gestion des unités de persistance multiple [Data]


Sujet :

Spring Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre très actif
    Avatar de Khaled.Noordin
    Homme Profil pro
    Inscrit en
    Janvier 2005
    Messages
    354
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 354
    Billets dans le blog
    1
    Par défaut Gestion des unités de persistance multiple
    Bonjour/Bonsoir
    Je suis bloqué sur la configuration gérant l'unité de persistance multiple,
    tout d'abords le problème ne vient pas du code java car quand j'utilise mon cas avec une seule unité de persistance cela fonctionne très bien et la génération de mes table réussi.
    J'ai suivie le documentation de référence, et l'exemple donné est très light.
    Ainsi, si une personne a déjà rencontré ce cas ou aimerais se pencher dessus j'en serais ravi.
    Voici les différents fichiers décrivant ma configuration.
    (spring 3.0.5 hibernate 3.6.5 JPA 2.0 logback),
    j'ai attaché au sujet un bout de la trace de log

    /config/persitence.xml
    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
     
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence version="2.0" 
    xmlns="http://java.sun.com/xml/ns/persistence" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence 
    http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
     
     <persistence-unit name="org-basisPU"
     transaction-type="RESOURCE_LOCAL">
      <mapping-file>config/orm.xml</mapping-file>
      <class>organization.basis.domain.model.Account</class>
      <class>organization.basis.domain.model.AccountAccess</class>
      <class>organization.basis.domain.model.AccountEmail</class>
      <class>organization.basis.domain.model.AccountEnabled</class>
      <class>organization.basis.domain.model.AccountRole</class>
      <class>organization.basis.domain.model.Browser</class>
      <class>organization.basis.domain.model.Email</class>
      <class>organization.basis.domain.model.I18n</class>
      <class>organization.basis.domain.model.Lang</class>
      <class>organization.basis.domain.model.Property</class>
      <class>organization.basis.domain.model.Role</class>
      <class>organization.basis.domain.model.Visitor</class>
      <exclude-unlisted-classes>true</exclude-unlisted-classes>
     </persistence-unit>
     
     <persistence-unit name="org_logPU"
     transaction-type="RESOURCE_LOCAL">
      <mapping-file>config/orm.xml</mapping-file>
      <class>organization.basis.domain.model.logging.LoggingEvent</class>
      <class>organization.basis.domain.model.logging.LoggingEventException</class>
      <class>organization.basis.domain.model.logging.LoggingEventProperty</class>
      <exclude-unlisted-classes>true</exclude-unlisted-classes>
     </persistence-unit>
     
    </persistence>

    /organization/basis/basis-dao-applicationContextSE.xml
    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     
           xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
     <import resource="classpath:/organization/basis/domain/dao/basis-dataSourceSE-context.xml"/>
     <import resource="classpath:/organization/basis/domain/dao/jpa/basis-daoJpa-context.xml"/>
    </beans>


    /organization/basis/domain/dao/basis-dataSourceSE-context.xml

    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
     
    <?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-3.0.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-3.0.xsd
           ">
     
     <context:annotation-config/>
     
    <!--loading property files about the datasources values-->
     <context:property-placeholder
     location="classpath:organization/basis/domain/dao/log-database_mysql.properties,
     classpath:organization/basis/domain/dao/basis-database_mysql.properties"/>
     
    <!--my datasource for logging the application events-->
     <bean id="log_datasource"
              class="org.springframework.jdbc.datasource.SingleConnectionDataSource">
      <property name="driverClassName" value="${log.database.driver}"/>
      <property name="url" value="${log.database.url}"/>
      <property name="username" value="${log.database.user}"/>
      <property name="password" value="${log.database.password}"/>
      <property name="suppressClose" value="${log.database.suppressclose}"/>
     </bean>
     
    <!--my datasource concerning the application itself-->
     <bean id="basis_datasource"
              class="org.springframework.jdbc.datasource.SingleConnectionDataSource">
      <property name="driverClassName" value="${basis.database.driver}"/>
      <property name="url" value="${basis.database.url}"/>
      <property name="username" value="${basis.database.user}"/>
      <property name="password" value="${basis.database.password}"/>
      <property name="suppressClose" value="${basis.database.suppressclose}"/>
     </bean>
     
    </beans>


    /organization/basis/domain/dao/jpa/basis-daoJpa-context.xml
    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
     
    <?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:util="http://www.springframework.org/schema/util"
           xmlns:context="http://www.springframework.org/schema/context"
     
           xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
           http://www.springframework.org/schema/util
           http://www.springframework.org/schema/util/spring-util-3.0.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-3.0.xsd
    ">
     <context:annotation-config/>
    	<!-- JPA annotations bean post processor -->
     <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>
    	<!-- Exception translation bean post processor -->
     <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>
     
     <util:properties id="log_jpaProperties" location="classpath:organization/basis/domain/dao/jpa/log-jpa_mysql.properties"/>
    <!-- <util:properties id="jpaProperties" location="classpath:organization/basis/domain/dao/jpa/basis-jpa_postgresql.properties"/>-->
     <util:properties id="basis_jpaProperties" location="classpath:organization/basis/domain/dao/jpa/basis-jpa_mysql.properties"/>
    <!-- <util:properties id="jpaProperties" location="classpath:organization/basis/domain/dao/jpa/basis-jpa_postgresql.properties"/>-->
     
     <bean id="jpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
      <property name="generateDdl" value="true"/>
     </bean>
     
    <!-- DEALING WITH MULTIPLE PERSISTENCE UNIT -->
     <bean id="persistenceUnitManager" class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
      <property name="persistenceXmlLocations">
       <list>
        <value>classpath:config/persistence.xml</value>
       </list>
      </property>
      <property name="dataSources">
       <map>
        <entry key="log_datasource" value-ref="log_datasource"/>
        <entry key="basis_datasource" value-ref="basis_datasource"/>
       </map>
      </property>
    </bean>
     
     <bean id="log_entityManagerFactory" 
     class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
      <property name="persistenceUnitManager" ref="persistenceUnitManager"/>
      <property name="persistenceUnitName" value="org-basisPU"/>
      <property name="jpaVendorAdapter" ref="jpaVendorAdapter"/>
      <property name="jpaProperties" ref="log_jpaProperties"/>
      <property name="dataSource" ref="log_datasource"/>
     </bean>
     
     <bean id="basis_entityManagerFactory" 
     class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
      <property name="persistenceUnitManager" ref="persistenceUnitManager"/>
      <property name="persistenceUnitName" value="org_logPU"/>
      <property name="jpaVendorAdapter" ref="jpaVendorAdapter"/>
      <property name="jpaProperties" ref="basis_jpaProperties"/>
      <property name="dataSource" ref="basis_datasource"/>
     </bean>
     
    </beans>

    /organization/basis/domain/dao/basis-database_mysql.properties

    Code properties : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    basis.database.driver=com.mysql.jdbc.Driver
    basis.database.server=
    basis.database.name=org_basis
    basis.database.user=org_usr
    basis.database.password=org
    basis.database.url=jdbc:mysql://localhost:3306/org_basis
    basis.database.schema=
    basis.database.port=3306
    basis.database.host=localhost
    basis.database.suppressclose=true
    basis.database.database=MYSQL


    /organization/basis/domain/dao/log-database_mysql.properties

    Code properties : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    log.database.driver=com.mysql.jdbc.Driver
    log.database.server=
    log.database.name=org_log
    log.database.user=org_usr
    log.database.password=org
    log.database.url=jdbc:mysql://localhost:3306/org_log
    log.database.schema=
    log.database.port=3306
    log.database.host=localhost
    log.database.suppressclose=true
    log.database.database=MYSQL


    /organization/basis/domain/dao/jpa/basis-jpa_mysql.properties

    Code properties : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    hibernate.cache.provider_class=org.hibernate.cache.NoCacheProvider
    hibernate.hbm2ddl.auto=create
    hibernate.cache.use_query_cache=false
    hibernate.cache.use_second_level_cache=false
    hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
    hibernate.show_sql=true


    /organization/basis/domain/dao/jpa/log-jpa_mysql.properties
    Code properties : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    hibernate.cache.provider_class=org.hibernate.cache.NoCacheProvider
    hibernate.hbm2ddl.auto=create
    hibernate.cache.use_query_cache=false
    hibernate.cache.use_second_level_cache=false
    hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
    hibernate.show_sql=true


    Merci d'avance de votre participation

    Cordialement, Khaled
    Fichiers attachés Fichiers attachés

  2. #2
    Membre très actif
    Avatar de Khaled.Noordin
    Homme Profil pro
    Inscrit en
    Janvier 2005
    Messages
    354
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 354
    Billets dans le blog
    1
    Par défaut
    La solution c'est un transaction manager et une datasource par unité de persistance.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 5
    Dernier message: 06/06/2013, 14h58
  2. [QThread] Problème de gestion des threads après connexions multiples sur un serveur
    Par vince-29 dans le forum Multithreading
    Réponses: 5
    Dernier message: 23/11/2010, 21h28
  3. Réponses: 7
    Dernier message: 30/09/2010, 17h01
  4. Gestion des contraintes d'intégritées multiples
    Par erehcab dans le forum Zend_Db
    Réponses: 2
    Dernier message: 09/12/2009, 23h28
  5. Gestion des erreurs sur une commande multiple
    Par domiq44 dans le forum Shell et commandes GNU
    Réponses: 5
    Dernier message: 05/10/2006, 15h03

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo