Unable to persist objects in GAE JDO

Posted by Basil Dsouza on Stack Overflow See other posts from Stack Overflow or by Basil Dsouza
Published on 2010-05-03T17:11:31Z Indexed on 2010/05/03 17:38 UTC
Read the original article Hit count: 252

Filed under:
|
|

Hello Guys,

I am completely fresh to both JDO and GAE, and have been struggling to get my data layer to persist any code at all!

The issues I am facing may be very simple, but I just cant seem to find any a way no matter what solution I try.

Firstly the problem: (Slightly simplified, but still contains all the info necessary) My data model is as such:

User:
    (primary key)
    String emailID
    String firstName

Car:
    (primary key)
    User user
    (primary key)
    String registration
    String model

This was the initial datamodel. I implemented a CarPK object to get a composite primary key of the User and the registration. However that ran into a variety of issues. (Which i will save for another time/question)

I then changed the design as such: User: (Unchanged)

Car:
(primary key)
String fauxPK (here fauxPK = user.getEmailID() + SEP + registration)
User user
String registration
String model

This works fine for the user, and it can insert and retrieve user objects. However when i try to insert a Car Object, i get the following error:

"Cannot have a java.lang.String primary key and be a child object"

Found the following helpful link about it:
http://stackoverflow.com/questions/2063467/persist-list-of-objects

Went to the link suggested there, that explains how to create Keys, however they keep talking about "Entity Groups" and "Entity Group Parents". But I cant seem to find any articles or sites that explain what are "Entity Group"s or an "Entity Group Parents"

I could try fiddling around some more to figure out if i can store an object somehow, But I am running sort on patience and also would rather understand and implement than vice versa.

So i would appreciate any docs (even if its huge) that covers all these points, and preferably has some examples that go beyond the very basic data modeling.

And thanks for reading such a long post :)

© Stack Overflow or respective owner

Related posts about google-app-engine

Related posts about jdo