aspose file tools*
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 Spring in Action this week in the Spring 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
Author

Entity name must be unique in a persistence unit

Daniel Jabonete
Ranch Hand

Joined: Apr 01, 2007
Posts: 78
Greetings!

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.

Cheers!
Daniel
Dennis Grimbergen
Ranch Hand

Joined: Nov 04, 2009
Posts: 142

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:

chapter5.overrideCollectionTableColumn.model.Employee
chapter5.manyToManyMap.model.Employee

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?


SCJP, SCWCD, SCJD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Entity name must be unique in a persistence unit