I have found a solution for creating owned relationships within an entity 
group, and still be portable, the best part, you dont need to manually 
handle key and parentKey. 
Check out my blog post at: 
http://blog.wp.weightpoint.se/2012/03/01/portable-owned-jdo-relations-appengine/

On Tuesday, May 19, 2009 3:14:59 PM UTC+2, mb wrote:
>
> Thanks Max, it does indeed work fine. 
>
> So basically what I needed to do was: 
>
> @PersistenceCapable(identityType = IdentityType.APPLICATION) 
> public class MyDomainObject { 
>
>     // Set parent key as an encoded string, manually 
>     @Persistent 
>     @Extension(vendorName="datanucleus", 
>         key="gae.parent-pk", value="true") 
>     private String parentKey; 
>
>     // This gets set automatically when object is made persistent. 
>     @PrimaryKey 
>     @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) 
>     @Extension(vendorName = "datanucleus", 
>         key = "gae.encoded-pk", value="true") 
>     private String key; 
>
>     public MyDomainObject(String encodedParentKey) { 
>         this.parentKey = encodedParentKey; 
>     } 
>
> ... 
>
> It seems that GAE/datanucleus is clever enough to figure out that the 
> parent key is an encoded string.  I had assumed that the above would 
> make it assume that the parent key was an unencoded String, as the 
> key=gae.parent-pk" doesn't specify that it's an encoded one. 
>
> Thanks for taking the time to point me in the right direction :) 
>
> On May 16, 12:32 am, Max Ross <maxr+appeng...@google.com> wrote: 
> > You should be able to do what you're describing without any dependencies 
> on 
> > app-engine classes. 
> > 
> > Here's a class that's part of the plugin test-suite that I believe 
> > demonstrates the behavior you're looking for:
> http://code.google.com/p/datanucleus-appengine/source/browse/trunk/te... 
> > 
> > And here's a testcase that illustrates setting a parent, leaving the id 
> > blank, and getting back a system generated id:
> http://www.google.com/codesearch/p?hl=en#79kbA0UmWLw/trunk/tests/org/... 
> > \.googlecode\.com 
> > 
> > Does this help? 
> > 
> > Max 
> > 
> > On Wed, May 13, 2009 at 3:07 PM, mb <mbrom...@gmail.com> wrote: 
> > 
> > > On May 13, 7:36 pm, mb <mbrom...@gmail.com> wrote: 
> > > > Actually I suppose the same problem applies to unowned relationships 
> > > > that aren't children.  It doesn't look like there's a way to do them 
> > > > without using com.google.appengine.api.datastore.Key in the domain 
> > > > model.  i.e. you can't use encoded strings as a substitute. 
> > 
> > > Oops, sorry I wasn't thinking when I posted that...  You can simply 
> > > store the encoded String as a regular String for unowned 
> > > relationships.  But for parent objects the problem remains, as 
> > > described in my first post.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-appengine-java/-/2jAfn0HXSjkJ.
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