Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/318.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
Java 具有NetBeans的两个JPA持久化单元的相同表名_Java_Jpa_Persistence - Fatal编程技术网

Java 具有NetBeans的两个JPA持久化单元的相同表名

Java 具有NetBeans的两个JPA持久化单元的相同表名,java,jpa,persistence,Java,Jpa,Persistence,My persistence.xml: <?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/persist

My persistence.xml:

<?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="first" transaction-type="RESOURCE_LOCAL">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <class>database.first.entity.Grupe</class>
        <properties>
             <property name="javax.persistence.jdbc.url" value="jdbc:mysql://*****/first"/>
             <property name="javax.persistence.jdbc.password" value="*****"/>
             <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
             <property name="javax.persistence.jdbc.user" value="*****"/>
        </properties>
    </persistence-unit>
    <persistence-unit name="second" transaction-type="RESOURCE_LOCAL">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <class>database.second.entity.Darbuotojas</class>
        <class>database.second.entity.Grupe</class>
        <properties>
              <property name="javax.persistence.jdbc.url" value="jdbc:mysql://*******/second"/>
              <property name="javax.persistence.jdbc.password" value="*****"/>
              <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
              <property name="javax.persistence.jdbc.user" value="*****"/>
        </properties>
    </persistence-unit>
</persistence>

是否有任何注释可以解决此问题,因为我不想创建具有不同类名的类,例如GrupeFirstgrupessecond,如果它们位于不同的持久化单元中,应该可以

尝试将设置为true,可能会查找这两个类,因为它们位于同一个jar文件中


除了重命名类,您还可以将@Entity上的名称设置为其他名称。

如果忽略该错误,会发生什么?你的应用程序是否按预期工作,或者eclipselink是否抱怨?@Minutis你是如何让Netbeans从两个同名表生成实体类的?我只能设法更新或重新创建类,即使它们在不同的包中……看起来没问题,我可以忽略这个错误。这是NetBeans错误。
Duplicated entity name. Class database.first.entity.Grupe is using the same name.