0

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>

As you see there is one Grupe class in each persistence unit. But when I try to create two @Entity classes with same Grupe name (but in different packages, therefore this shouldn't be a problem) NetBeans gives me error:

Duplicated entity name. Class database.first.entity.Grupe is using the same name.

Is there any annotations witch could solve this problem, because I don't want to create classes with different class names like GrupeFirst and GrupeSecond.

2
  • 1
    What happens if you just ignore the error? Does your app work as expected, or does eclipselink complain? Commented Jun 20, 2012 at 11:34
  • @Minutis How did you even manage to get Netbeans to generate entity classes from two tables with the same name? I can only manage to UPDATE or RECREATE the class, even if they are in different packages... Commented Dec 11, 2012 at 12:22

1 Answer 1

1

It should be ok if they are in different persistence units.

Try setting to true, it might be finding both classes because they are in the same jar file.

Instead of renaming the class you can also just set the name on the @Entity to a different name.

Sign up to request clarification or add additional context in comments.

1 Comment

It seems to be ok, I can just ignore that error. It's NetBeans bug.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.