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
Partager