Back to work after the holidays :-).
I changed the inner class to be a separate entity by itself, and then
it works perfectly fine.
It makes no sense to have that class "public" in my context, so I want
to have it embedded,
which leaves me with the same question..what am I doing wrong in the
embedded case?

BR, Andreas

On 23 Dec, 13:38, andreas_b <[email protected]> wrote:
> Hi.
>
> I'm using 1.3.0, but further investigations shows that this might not
> be related to lazy loading after all.
> I don't seem to be able to save/retrieve lists of embedded objects at
> all...
>
> I wrote some test examples to show my problem. I probably do something
> wrong here, but I really can't figure out what...
>
> @PersistenceCapable(identityType = IdentityType.APPLICATION)
> public class Test {
>
>     @PrimaryKey
>     @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
>     @Extension(vendorName="datanucleus", key="gae.encoded-pk",
> value="true")
>     private String iEncodedKey;
>
>     @Persistent(defaultFetchGroup = "true")
>     private List<InnerTest> innerTests;
>
>     @PersistenceCapable
>     @EmbeddedOnly
>     public static class InnerTest{
>
>         @Persistent
>         private String whatever;
>
>         public InnerTest(){
>                 whatever = "whatever";
>         }
>     }
>
>     public Test(){ }
>
>     public void addSomeInnerTests(){
>         innerTests = new ArrayList<InnerTest>();
>
>         for(int i = 0; i < 5; ++i)
>                 innerTests.add(new InnerTest());
>     }
>
>     public List<InnerTest> getInnerTests(){
>         return innerTests;
>     }
>
> }
>
> and then I use the following testcode to save and retrieve the objects
>
> // For saving
> Test test = new Test();
> test.addSomeInnerTests();
>
> Test saved = pm.makePersistent(test);
> System.out.println("persisted Test innerTests size = " +
> saved.getInnerTests().size());
> System.out.println("Saved Test key = " + saved.getKey());
>
> // For retrieving
> Query query = pm.newQuery(Test.class);
> List<Test> list = (List<Test>)query.execute();
> System.out.println("Tests = " + list.size());
>
> for(Test test : list){
>         System.out.println("Retrieved Test key = " + test.getKey());
>         List<InnerTest> innerTests = test.getInnerTests();
>         System.out.println("innerTests size = " + innerTests.size());
>
> }
>
> and this provides the following output
>
> persisted Test innerTests size = 5
> Saved Test key = agtib2xsdHJvbGxlbnIMCxIEVGVzdBjbsAEM
> Tests = 1
> Retrieved Test key = agtib2xsdHJvbGxlbnIMCxIEVGVzdBjbsAEM
> innerTests size = 0
>
> So, why is the List in the retrieved Test empty? I have tried
> retrieving an object directly as well, but this naturally leads to an
> IndexOutOfBounds.
> In my real code, all the other variables are saved and retrieved
> properly. I have Lists of Strings and such as well, and they work just
> fine, so its definitely related to children/embedded objects.
>
> Any help is appreciated.
>
> Thanks / Andreas
>
> On 23 Dec, 07:32, "Ikai L (Google)" <[email protected]> wrote:
>
> > Embedded objects should be eager loaded with any SDK version 1.2.8+ and
> > above. Is this the version you are on? It's only child objects that are not
> > eager loaded now.
>
> > On Tue, Dec 22, 2009 at 3:15 PM, andreas_b <[email protected]>wrote:
>
> > > Hi all.
>
> > > I'm struggling a bit with default fetch groups in one of my entities
> > > here..
>
> > > Basically I have something that looks like this
>
> > > @PersistenceCapable(identityType = IdentityType.APPLICATION,
> > > detachable="true")
> > > public class A {
>
> > > �...@persistent(defaultFetchGroup = "true")
> > >  private List<B> embeddedObjects;
>
> > > �...@persistencecapable(detachable="true")
> > > �...@embeddedonly
> > >  public static class B {
> > >  ....
> > >  }
> > > }
>
> > > I want the list of my B objects to be fetched automatically when I
> > > retrieve A from the datastore. This does not work however. It still
> > > seems to do lazy loading and I get the following warning:
>
> > > 2009-dec-22 23:57:52 org.datanucleus.store.appengine.MetaDataValidator
> > > warn
> > > WARNING: Meta-data warning for A.embeddedObjects: The datastore does
> > > not support joins and therefore cannot honor requests to place child
> > > objects in the default fetch group.  The field will be fetched lazily
> > > on first access..."
>
> > > The above works fine if I change it to just: private B object, so the
> > > problem seems related to List or collections in general. I have been
> > > trying to find some explanation on this both in datanucleus docs and
> > > here, but have been unable to find it.
>
> > > Oh, and I can't use the "touch" technique since I use generic object
> > > retrieval and that code has no knowledge of what the class contains,
> > > and I want to keep it that way.
>
> > > Could someone explain how this works (or point me to someplace) and
> > > how I can solve it?
>
> > > Thanks in advance.
>
> > > BR, Andreas
>
> > > --
>
> > > 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
> > > [email protected].
> > > To unsubscribe from this group, send email to
> > > [email protected]<google-appengine-java%[email protected]>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/google-appengine-java?hl=en.
>
> > --
> > Ikai Lan
> > Developer Programs Engineer, Google App Engine

--

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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.


Reply via email to