Details
-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
None
-
None
Description
create a new persistence unit programmatically and map it to a new datasource without redeploy or server restart.
We tried the following in a stateless session bean:
Map configOverrides = new HashMap();
EntityManagerFacotry emf = Persistence.createEntityManagerFactory("unit1", configOverrides);
But got exception:
javax.persistence.PersistenceException: [PersistenceUnit: unit1] Unable to build EntityManagerFactory
<persistence-unit name="unit1">
<jta-data-source>java:/dataSource1</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.show_sql" value="false"/>
</properties>
</persistence-unit>
08:17:58,204 ERROR [STDERR] javax.persistence.PersistenceException: [PersistenceUnit: defaultDataSource] Unable to build EntityManagerFactory
08:17:58,205 ERROR [STDERR] at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:677)
08:17:58,205 ERROR [STDERR] at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:126)
08:17:58,205 ERROR [STDERR] at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:52)