Answers below.

--
Ikai Lan
Developer Programs Engineer, Google App Engine
plus.ikailan.com



On Tue, Jan 17, 2012 at 9:24 AM, Paul Bartosik <paulhbarto...@gmail.com>wrote:

> I have spent a bit of time banging up against Entity Group issues.  In
> all cases, the problem was with my JPA.  I had made mistakes in my
> annotations that manifested as run-time transaction and Entity Group
> errors .
>
> The documentation on JPA relationships and Entity Groups is pretty
> light.  Can someone confirm my 3 assumptions below?
>
> 1. In a bi-directional relationship, the unowned side of the
> relationship will automatically be the Parent Entity and the owned
> side will be the Child Entity.
>

No, there's nothing automatic about parent and child entity relationships
with regards to JPA. In JPA parlance, "parent" and "child" refer to a
one-many relationship, whereas in an entity group, the "ancestry" of an
entity is embedded entirely within its key.


>
> 2. In a uni-directional relationship, both sides of the relationship
> will be in different Entity Groups.
>
> Again, there's nothing automatic about this.


> 3. When using JPA, there is no other way to specify the Entity Group
> of your entities.
>

You can specify the entity groups of an entity by constructing the key via
a KeyFactory:

http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/datastore/KeyFactory.Builder.html

A lot of this confusion may come from the fact that the entity group
concept does not map well to JDO/JPA. In a relational database, a single
entity can have 1:N mappings to many different kinds of "child" entities (a
School can have many Students, Teachers and Specialities, for instance),
whereas an entity group is a single, hierarchical structuring of data (a
User has many Blogs which have Entries which each have Comments).

Do you have any experience with the low-level API? You'll develop some
familiarity with datastore concepts if you take a look at it for a bit.


>
>
> Thanks for any help.
>
> -Paul
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine for Java" group.
> To post to this group, send email to
> google-appengine-java@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengine-java+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to