surinder-insonix / datanucleus-appengine

Automatically exported from code.google.com/p/datanucleus-appengine
0 stars 0 forks source link

In JPA, Persist entity that contains another already persisted entity #302

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.Create class (City) and persist it using EntityManager 
2.Create class (Address), and it contains the city class as a composite 
relationship (oneToOne).
3.Try to persist Address class.

What is the expected output? What do you see instead?
After step 3, I got an exception:
javax.persistence.PersistenceException: Detected attempt to establish 
Address(no-id-yet) as the parent of City(20) but the entity identified by 
City(20) has already been persisted without a parent.  A parent cannot be 
established or changed once an object has been persisted.
How I can persist it? the user defines(persist) the city object in order to use 
it.

What version of the product are you using? On what operating system?
datanucleus-appengine-2.0.0
Windows 7

Please provide any additional information below.
I am try to persist an instance (entity) that contains a predefined 
instances(entities), with JPA and GAE I got the exception mention above, Is 
there any annotation(s) should be used in order to make this happen?

Thanks in advance 

Original issue reported on code.google.com by rkhaly...@gmail.com on 6 Oct 2012 at 8:27

GoogleCodeExporter commented 8 years ago
Defining a testcase that fits in 
http://code.google.com/p/datanucleus-appengine/source/browse/#svn%2Ftrunk%2Ftest
s_bugs%2Fcom%2Fgoogle%2Fappengine%2Fdatanucleus%2Fbugs%2Ftest is the way to 
demonstrate what you're talking about. GAE doesn't support compound identity 
AFAIK but maybe that's not what you're talking about (hence why testcases are 
required)

Original comment by googleco...@yahoo.co.uk on 7 Oct 2012 at 6:17

GoogleCodeExporter commented 8 years ago
In fact it seems you also posted on stackoverflow at 
http://stackoverflow.com/questions/12763790/google-app-engine-and-jpa
with more detail. I see nothing in that post of anything incorrect in GAE 
handling of "owned relations"; you can obviously use unowned relations, or 
change your order of persist.

Original comment by googleco...@yahoo.co.uk on 7 Oct 2012 at 11:16