Re: [appengine-java] JPA and Entity Groups

2012-01-18 Thread Ikai Lan (Google)
Yep, just double checked. JPA's @OneToMany has absolutely nothing to do
with entity group hierarchies. You'll have to use KeyFactory. Re-read my
original email and ignore the one that begins with "on second examination
.. ".

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



On Wed, Jan 18, 2012 at 11:48 AM, Ikai Lan (Google) wrote:

> On second examination, I could be wrong about JPA. I'll need to test this
> and see.
>
>
> http://stackoverflow.com/questions/4909012/how-to-create-an-object-in-a-specific-entity-group-with-jpa-google-appengine-j
>
> If you get around to this before me, can you let me know if it works?
>
> Note that as of a recent release, you can do cross entity-group
> transactions.
>
>  --
> Ikai Lan
> Developer Programs Engineer, Google App Engine
> plus.ikailan.com
>
>
>
> On Wed, Jan 18, 2012 at 11:22 AM, Ikai Lan (Google) wrote:
>
>> Answers below.
>>
>> --
>> Ikai Lan
>> Developer Programs Engineer, Google App Engine
>> plus.ikailan.com
>>
>>
>>
>> On Tue, Jan 17, 2012 at 9:24 AM, Paul Bartosik 
>> 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.



Re: [appengine-java] JPA and Entity Groups

2012-01-18 Thread Ikai Lan (Google)
On second examination, I could be wrong about JPA. I'll need to test this
and see.

http://stackoverflow.com/questions/4909012/how-to-create-an-object-in-a-specific-entity-group-with-jpa-google-appengine-j

If you get around to this before me, can you let me know if it works?

Note that as of a recent release, you can do cross entity-group
transactions.

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



On Wed, Jan 18, 2012 at 11:22 AM, Ikai Lan (Google) wrote:

> Answers below.
>
> --
> Ikai Lan
> Developer Programs Engineer, Google App Engine
> plus.ikailan.com
>
>
>
> On Tue, Jan 17, 2012 at 9:24 AM, Paul Bartosik 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.



Re: [appengine-java] JPA and Entity Groups

2012-01-18 Thread Ikai Lan (Google)
Answers below.

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



On Tue, Jan 17, 2012 at 9:24 AM, Paul Bartosik 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.



Re: [appengine-java] JPA and Entity Groups

2012-01-17 Thread Matthew Jaggard
Cough objectify cough
On 17 Jan 2012 19:49, "Paul Bartosik"  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.
>
> 2. In a uni-directional relationship, both sides of the relationship
> will be in different Entity Groups.
>
> 3. When using JPA, there is no other way to specify the Entity Group
> of your entities.
>
>
> 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.



[appengine-java] JPA and Entity Groups

2012-01-17 Thread Paul Bartosik
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.

2. In a uni-directional relationship, both sides of the relationship
will be in different Entity Groups.

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


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.