我正在使用WildFly Web服务器开发Java EE应用程序。出于某些原因,我需要重新创建EntityManagerFactory,但是在创建之后,元模型中的实体计数为零。 这是我的代码:
Map properties = new HashMap();
properties.put("hibernate.show_sql", true);
properties.put("javax.persistence.jdbc.url", "jdbc:oracle:thin:@//localhost:1521/XE");
properties.put("javax.persistence.jdbc.user", "xx");
properties.put("javax.persistence.jdbc.password", "xx");
properties.put("javax.persistence.jdbc.driver", "oracle.jdbc.driver.OracleDriver");
properties.put("hibernate.dialect", "org.hibernate.dialect.Oracle12cDialect");
properties.put("hibernate.archive.autodetection", "class");
EntityManagerFactory emf = Persistence.createEntityManagerFactory("dynamicPU", properties);
EntityManager dynamicEm = emf.createEntityManager();
的persistence.xml
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
version="2.1">
<persistence-unit name="dynamicPU" transaction-type="JTA">
</persistence-unit>
</persistence>
有谁知道发生了什么事?