title: JPA EntityExistsException
body: <p>The problem that I'm currently facing is the following:</p>
  
  <pre><code>Exception in thread "main" javax.persistence.EntityExistsException: a different object with the same identifier value was already associated with the session: [de.entities.Genre#28]
  at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1359)
  at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1310)
  at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1316)
  at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:881)
  at de.model.DatabaseBuilder.importData(DatabaseBuilder.java:87)
  at de.main.Main.main(Main.java:55)
  </code></pre>
  
  <p>So the Exception tells me that I want to insert two different objects with the same primary key id.</p>
  
  <p>All my datas I want to insert into a database using JPA are coming from an XML file. I parse this file with a SAXParser. Of course there are many genre entries with the id 28 because many movies have the same genre.</p>
  
  <p>If I use auto-generated ids, the data wont be correct anymore because all id's are correctly given by the XML file.</p>
  
  <p>How can I solve this problem? Why isn't JPA not just ignoring the fact, that this object is already present in the database and just inserting the ids of the movies and the genres in my m:n table?</p>