Just so you know, I think I have solved the problem by setting
defaultFetchGroup="true" on the Key property:

@Persistent(defaultFetchGroup="true")
private Key text;

Might have something to do with the recently closed issue #58 "Queries
don't respect fetch groups": 
http://code.google.com/p/datanucleus-appengine/issues/detail?id=58

What's puzzling is that I have unowned relationships all over the
application, however only one class - CMSPage - fails to retrieve the
Key properties.

I am not sure why Key is not automatically in the default fetch group.
Key is not an entity class. It should be ok to fetch it non-lazily by
default.

Yegor

On Sep 4, 1:21 pm, Yegor <yegor.jba...@gmail.com> wrote:
> Hi,
>
> I am experiencing a problem after upgrading to Java SDK 1.2.5. In a
> simple CMS application a page is stored as a CMSPage entity, which
> points to its text saved as a DetachedText entity using a Key property
> (i.e. an unowned relationship) as follows:
>
> @PersistenceCapable(identityType = IdentityType.APPLICATION)
> public class CMSPage {
>
>   @PrimaryKey
>   @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
>   private Key id;
>
>   @Persistent
>   private Key text;
>
>   public Key getId() {
>     return id;
>   }
>
>   public void setId(Key id) {
>     this.id = id;
>   }
>
>   public Key getText() {
>     return text;
>   }
>
>   public void setText(Key text) {
>     this.text = text;
>   }
>
> }
>
> The Key property "text" points to:
>
> @PersistenceCapable(identityType = IdentityType.APPLICATION)
> public class DetachedText {
>
>   @PrimaryKey
>   @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
>   private Key id;
>
>   @Persistent
>   private Text content;
>
>   public DetachedText(Text content) {
>     this.content = content;
>   }
>
>   public Key getId() {
>     return id;
>   }
>
>   public Text getContent() {
>     return content;
>   }
>
> }
>
> NOTE: I have removed other properties and code that I found unrelated
> to the problem
>
> After saving the page I can see the "text" field populated in the
> development console. The value shows as "DetachedText(5)". I also
> verified that the DetachedText entity exists and its ID equals 5.
>
> However, after I retrieve CMSPage from the datastore using a
> javax.jdo.Query the "text" field in the retrieved object is null (both
> the Eclipse debugger and the application throwing NPE confirm it).
>
> What am I doing wrong?
>
> Any pointers will be appreciated.
>
> Thanks,
>
> Yegor
--~--~---------~--~----~------------~-------~--~----~
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