我的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>
如您所见,每个持久性单元中都有一个Grupe类。但是当我尝试创建两个@Entity
具有相同Grupe名称的类时(但在不同的包中,因此这应该不是问题)NetBeans 给了我错误:
Duplicated entity name. Class database.first.entity.Grupe is using the same name.
是否有任何注释可以解决这个问题,因为我不想创建具有不同类名的类,如GrupeFirst和GrupeSecond。