MountainClimb / datanucleus-appengine

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

many-to-one entity relationship not supported / undocumented #248

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1. create a many-to-one entity relationship (e.g. A->B), where the relation is 
mapped by the "many" (A) party. B is in relationship with another entity, C.
2. try to persist a new A entity instance coupled to a persistent B entity

What is the expected output? What do you see instead?

Expected: the entity is persisted, relationship is established
Instead: the following Exception is thrown:

Detected attempt to establish A as the parent of B but the entity identified by 
B is already a child of C. 
A parent cannot be established or changed once an object has been persisted.
org.datanucleus.store.appengine.DatastoreRelationFieldManager$ChildWithWrongPare
ntException: A parent cannot be established or changed once an object has been 
persisted.
    at org.datanucleus.store.appengine.DatastoreRelationFieldManager.checkForParentSwitch(DatastoreRelationFieldManager.java:211)
    at org.datanucleus.store.appengine.DatastoreRelationFieldManager$1.setObjectViaMapping(DatastoreRelationFieldManager.java:134)
    at org.datanucleus.store.appengine.DatastoreRelationFieldManager$1.apply(DatastoreRelationFieldManager.java:113)
    at org.datanucleus.store.appengine.DatastoreRelationFieldManager.storeRelations(DatastoreRelationFieldManager.java:82)
    at org.datanucleus.store.appengine.DatastoreFieldManager.storeRelations(DatastoreFieldManager.java:959)
    at org.datanucleus.store.appengine.DatastorePersistenceHandler.storeRelations(DatastorePersistenceHandler.java:585)
    at org.datanucleus.store.appengine.DatastorePersistenceHandler.insertPostProcess(DatastorePersistenceHandler.java:320)
    at org.datanucleus.store.appengine.DatastorePersistenceHandler.insertObjects(DatastorePersistenceHandler.java:272)
    at org.datanucleus.store.appengine.DatastorePersistenceHandler.insertObject(DatastorePersistenceHandler.java:256)
    at org.datanucleus.state.JDOStateManagerImpl.internalMakePersistent(JDOStateManagerImpl.java:3185)
    at org.datanucleus.state.JDOStateManagerImpl.makePersistent(JDOStateManagerImpl.java:3161)
    at org.datanucleus.ObjectManagerImpl.persistObjectInternal(ObjectManagerImpl.java:1298)
    at org.datanucleus.ObjectManagerImpl.persistObject(ObjectManagerImpl.java:1175)
    at org.datanucleus.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:669)
    at org.datanucleus.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:694)

What version of the product are you using? On what operating system?
datanucleus-core: 1.1.5
datanucleus-appengine: 1.0.9
Windows XP, GAE-SDK 1.5.2

Please provide any additional information below.

From the exception text we may conclude, that this is an unsupported use case 
with Datanucleus+Appengine.

It would make sense to document it at: 
- The Unsupported features of JDO section 
http://code.google.com/appengine/docs/java/datastore/jdo/overview.html
- Entity Relationships in JDO 
http://code.google.com/appengine/docs/java/datastore/jdo/relationships.html

I find the major benefit of using JDO in general is that relationships are 
managed by the JDO implementation. However based on the experiences with 
Appengine datastore, developers should in cases implement these relations 
themselves (in this case with a Set<Key> on the "many" side). So the balance is 
shifted from generic solution to customized data access logic. 

To make things easier I would propose to create a bullet-list guideline how to 
migrate existing JDO entities (wrt. restrictions with keys, relationships, 
unsupported features etc.) to Appengine. 
I know, it's a long list, but worth the effort.
People with existing JDO experience with e.g. relational datastore would 
appreciate it.

Original issue reported on code.google.com by testmail...@gmail.com on 27 Aug 2011 at 7:21

GoogleCodeExporter commented 8 years ago

Original comment by googleco...@yahoo.co.uk on 21 Sep 2011 at 3:53

GoogleCodeExporter commented 8 years ago
This is a documentation requirement and this project has no control over the 
docs for Google Appengine, so I've moved the issue to their project as 
http://code.google.com/p/googleappengine/issues/detail?id=7468&thanks=7468&ts=13
36327763

Original comment by googleco...@yahoo.co.uk on 6 May 2012 at 6:10