surinder-insonix / datanucleus-appengine

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

Mixing unowned and owned relations in a type throws exception #307

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. have two many to one relationships with one unowned 

What is the expected output? What do you see instead?
doesn't persist and fails with error 
javax.jdo.JDOException: App Engine ORM does not support multiple parent key 
provider fields.

What version of the product are you using? On what operating system?
2.1.1

Please provide any additional information below.
The unit tests used in the library are incomplete since the test doesn't try to 
persist an entity with one owned and one unowned (many to one) relationship
Therefore the test succeeds since it considers the unowned relationship as a 
parent

I joined a rectified version of the official unit tests : 
JDOUnownedOneToManyTest with only one method for the bi directional unowned test

The change is that I added in UnownedJDOOneToManyBiSideB a parent and children 
owned relationship to it self (keeping the "unowned" old field "related" ).

The relevant code is this one 
    @Persistent
    @Unowned
    private UnownedJDOOneToManyBiSideA related;

    @Persistent
    private UnownedJDOOneToManyBiSideB parent;

    @Persistent(mappedBy = "parent")
    private Set<UnownedJDOOneToManyBiSideB> children = new HashSet<UnownedJDOOneToManyBiSideB>();

Please try the unit tests with this change: the test fails with the error 
message " App Engine ORM does not support multiple parent key provider fields."

Best Regards,
Zied Hamdi
http://1vu.fr

Original issue reported on code.google.com by zhamdi.into on 13 Nov 2012 at 3:38

Attachments:

GoogleCodeExporter commented 8 years ago
Actually no, it is not considered an owned relation as far as the datastore is 
concerned (as evidenced by what is pushed to the datastore). The problem is 
solely at runtime in (legacy) GAE plugin code that has the unowned field as 
being a "parent provider field" and the (owned) check gets confused when it 
tries to have your (illegal) owned relation field also as the parent provider. 
I say "illegal" (in the provided test) since you will otherwise (with SVN 
trunk, fixing the parent provider message) get a message about 
Error in meta-data for field 
com.google.appengine.datanucleus.test.jdo.UnownedJDOOneToManyBiSideB.id : 
Cannot have a primary key of type java.lang.Long and be a child object (owning 
field is 
"com.google.appengine.datanucleus.test.jdo.UnownedJDOOneToManyBiSideB.children")

Clearly having some objects of a type that are owned and some of that type that 
are unowned will lead to problems of understanding in your model, but then 
that's your choice.

SVN trunk fixes that "parent provider" problem.

Original comment by googleco...@yahoo.co.uk on 19 Nov 2012 at 4:10

GoogleCodeExporter commented 8 years ago

Original comment by googleco...@yahoo.co.uk on 19 Nov 2012 at 4:11

GoogleCodeExporter commented 8 years ago
Same problem.

Original comment by sara.sa...@gmail.com on 19 Apr 2013 at 11:45