File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Entity name must be unique in a persistence unit

 
Daniel Jabonete
Ranch Hand
Posts: 84
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 159
IntelliJ IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic