Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jpa 向EntityManagerFactory动态添加托管类名_Jpa_Eclipselink_Persistence.xml - Fatal编程技术网

Jpa 向EntityManagerFactory动态添加托管类名

Jpa 向EntityManagerFactory动态添加托管类名,jpa,eclipselink,persistence.xml,Jpa,Eclipselink,Persistence.xml,假设我有一个persistence.xml文件,如下所示: org.eclipse.persistence.jpa.PersistenceProvider 实体1.E1 实体2.E2 实体3.E3 假的 我知道我可以从这样的代码更改persistence.xml文件,但只能更改properties部分: Properties属性=新属性(); properties.put(“javax.persistence.jdbc.url”,”); properties.put(“eclipseelin

假设我有一个persistence.xml文件,如下所示:


org.eclipse.persistence.jpa.PersistenceProvider
实体1.E1
实体2.E2
实体3.E3
假的
我知道我可以从这样的代码更改persistence.xml文件,但只能更改properties部分:

Properties属性=新属性();
properties.put(“javax.persistence.jdbc.url”,”);
properties.put(“eclipseelink.logging.level”和“”);
....
emf=Persistence.createEntityManagerFactory(“pu”,属性);
我可以通过反射获得所有实体类,但是如何以类似于属性的方式动态添加类名(示例中为E1..E3)

我知道Hibernate有,但我用的是eclipselink。
EclipseLink JPA实现有什么方法可以做到吗?

我最初花了很多时间在这个问题上,现在已经放弃了我最初的想法(动态添加实体类)。
所以,如果你读了这个问题,我自己的答案是,我很确定这是不可能的。

我最初在这个问题上花了很多时间,并且放弃了我最初的想法(动态添加实体类)。
因此,如果你读到这个问题,我自己的答案是,我非常确定这是不可能的。

我可以在那里找到一种非常手动的方式:--但是你必须手动描述实体(所有字段、连接…),所以这真的不实用。我可以在那里找到一种非常手动的方式:--但是你必须手动描述实体(所有字段、联接…),因此它实际上不实用。