Sorry, I found that it caused by the mistake my sleepy head made:
I had defaultFetchGroup attribute on Persistent annotation statement
for the child field in the parent object, but not for the parent field
in the child object in those class files.

Please ignore the post.
Warm regards,
Art

On Jul 22, 11:09 pm, Art <art...@gmail.com> wrote:
> Dear group,
>
> Would you mind asking the reason why, in owned one-to-many
> relationship, parent filed in child object which is obtained via query
> becomes null?
> That is actually asked at the below posts, but I did not see the
> answer.http://groups.google.com/group/google-appengine-java/browse_frm/threa...http://groups.google.com/group/google-appengine-java/browse_frm/threa...
>
> By using the Book class and Chapter class 
> fromhttp://groups.google.com/group/google-appengine-java/browse_frm/threa...
>
> public void testRelation() throws Exception {
>         Book b = new Book();
>         b.title = "JDO 4eva";
>
>         Chapter c1 = new Chapter();
>         c1.title = "Intro";
>         c1.numPages = 10;
>
>         b.chapters.add( c1);
>
>         Chapter c2 = new Chapter();
>         c2.title = "Configuration";
>         c2.numPages = 9;
>         b.chapters.add( c2);
>
>         pm = pmf.getPersistenceManager();
>         pm.setDetachAllOnCommit( true);
>         pm.currentTransaction().begin();
>         try {
>                 pm.makePersistent( b);
>                 pm.currentTransaction().commit();
>
>                 assertEquals( b, c1.book);
>                 assertEquals( b, c2.book);
>
>         } finally {
>                 if (pm.currentTransaction().isActive()) {
>                         pm.currentTransaction().rollback();
>                 }
>                 pm.close();
>         }
>
>         // Confirm on child field in parent object
>         pm = pmf.getPersistenceManager();
>         Query query = pm.newQuery( Book.class);
>         List<Book> bookList = (List<Book>)query.execute();
>         // Sanity check on book
>         assertEquals( 1, bookList.size());
>         Book bookEntityGroup = bookList.get( 0);
>         assertEquals( b.title, bookEntityGroup.title);
>         // Sanity check on chapters field
>         assertEquals( 2, bookEntityGroup.chapters.size());
>         for( Chapter chapter : bookEntityGroup.chapters) {
>                 assertTrue(
>                                 chapter.title.equals( c1.title) ? true :
> chapter.title.equals( c2.title) ? true : false
>                                 );
>         } // for
>         pm.close();
>
>         // Confirm on parent field in child object
>         pm = pmf.getPersistenceManager();
>         query = pm.newQuery( Chapter.class);
>         List<Chapter> chapterList = (List<Chapter>)query.execute();
>         assertEquals( 2, chapterList.size());
>         for( Chapter chapter : chapterList) {
>                 assertTrue(
>                                 chapter.title.equals( c1.title) ? true :
> chapter.title.equals( c2.title) ? true : false
>                                 );
>                 assertNotNull( chapter.book);   // This fails
>         } // for
>         query.close( chapterList);
>         pm.close();
>
> }
>
> Warm regards,
> Art

-- 
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-j...@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