[Gemini JPA] Storing entities with referenced entities leads to doubled entries [message #1244038] |
Tue, 11 February 2014 15:42  |
Eclipse User |
|
|
|
Hi all,
I've a Document entity which references a Contact entity:
public class Document implements Serializable {
private Contact contact = null;
}
Now, I create a new Contact and store it in database. Later on, I find
this Contact via a finder method from a DAO:
Contact contact = contactDAO.findById(129L); // ID is only as an example!
Then I create a new Document and assign this Contact to the Document:
Document document = new Document();
document.setContact(contact);
After saving the Document the Contact entry in my database is doubled
(with a new ID, respectively). I thought if I use the Contact from the
persistence context (where it resides because I'm used the Finder) this
has to be managed by the EntityManager. What's wrong with it?
TIA,
Ralf.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03320 seconds