This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JPA Certification (OCEJPA) and the fly likes Entity name must be unique in a persistence unit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » JPA Certification (OCEJPA)
Bookmark "Entity name must be unique in a persistence unit" Watch "Entity name must be unique in a persistence unit" New topic

Entity name must be unique in a persistence unit

Daniel Jabonete
Ranch Hand

Joined: Apr 01, 2007
Posts: 76

I am hoping you could kindly help me with the error I am encountering as describe below.

I am trying to separate my entities via package, like the following below:

- manyToManyMap.model.Employee
- overrideCollectionTableColumn.model.Employee

And I am trying to define a separate persistence-unit in my persistence.xml for each package, please see below:

But went I tried to deploy it in Glassfish 3.1 from Eclipse (Juno) the following error prompts:

I am not sure if this is a bug, or I am missing something in JPA 2.0. I already tried to provide different name for each "Employee" entity, but there was an error in persisting an object.

Is there a work around for these scenario, or I might just need to create a separate project for each persistence unit.

Thank you in advance for your insights, time and assistance.

Dennis Grimbergen
Ranch Hand

Joined: Nov 04, 2009
Posts: 140

Edit: Now I see you already tried this:
You can set the name of an entity explicitely by specifying it in the @Entity annotation like:


If you omit the name attribute then the class name of the entity is taken as it name. In your case both 'Employee' (even though both entities were in different packages).

What error did you get in persisting an entity?

subject: Entity name must be unique in a persistence unit
Similar Threads
SEVERE: Exception while preparing the app : Exception [EclipseLink-28018]
Module does not deploy for oracle but does for derby in Netbeans IDE
Caused by: javax.naming.NameNotFoundException: pools
How To USe JPA with Entity Bean in Ejb3.0
Unable to find database