Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Gemini » [Gemini JPA] Storing entities with referenced entities leads to doubled entries
[Gemini JPA] Storing entities with referenced entities leads to doubled entries [message #1244038] Tue, 11 February 2014 20:42 Go to next message
Ralf Heydenreich is currently offline Ralf HeydenreichFriend
Messages: 132
Registered: July 2009
Senior Member
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.
Re: [Gemini JPA] Storing entities with referenced entities leads to doubled entries [message #1256569 is a reply to message #1244038] Tue, 25 February 2014 15:16 Go to previous message
Michael Keith is currently offline Michael KeithFriend
Messages: 216
Registered: July 2009
Senior Member
Hi Ralf,

That could be a problem with your relationship management (is it bidirectional, and if so are you setting the backpointer from contact to document), your configuration (are there any cascading settings), or your logic code (what does the DAO do to get the contact and what is the scope of the persistence context). With JPA having DAOs is an anti-pattern and is unnecessary. You might want to get help on the EclipseLink forum if you haven't found your problem yet.

Mike
Previous Topic:Where to find the Spring dependencies?
Next Topic:Is Eclipse Gemini Blueprint still active?
Goto Forum:
  


Current Time: Tue Dec 23 00:59:09 GMT 2014

Powered by FUDForum. Page generated in 0.03075 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software