users@glassfish.java.net

Re: JPA Persisting Problem with sub objects

From: <glassfish_at_javadesktop.org>
Date: Mon, 13 Aug 2007 07:39:32 PDT

Hello Derrick,

em.merge() on you new AccountAddress will give you the managed object which should still have its Pk. If you call persist on it while it references an existing (detached) Account, you should get either an EntityExistsException or another PersistenceException at commit - which is what you will get when it tries to insert the Account. So either use merge on AccountAddress, or persist the AccountAddress and associate it to a managed Account.

I'm not sure why though why the existence check isn't able to tell that the Account already exists. Whats the version you are using?

Regards,
Chris
[Message sent by forum member 'chris_delahunt' (chris_delahunt)]

http://forums.java.net/jive/thread.jspa?messageID=230647