I have the following 3-part owned relationship...

Users, the root entity, have a collection of Decks, as such (I am not
including the specific subclass of User as it doesn't seem to be
relevant):

@PersistenceCapable(identityType = IdentityType.APPLICATION)
@Inheritance(strategy = InheritanceStrategy.SUBCLASS_TABLE)
public abstract class User {
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    protected Key _ID;

    @Persistent
    protected String _UniqueIdentifier;

    @Persistent(defaultFetchGroup = "true", mappedBy = "_Owner")
    @Element(dependent = "true")
    protected Set<Deck> _Decks;

        protected KleioUser()
    {
    }
}

Each Deck has a collection of Cards, as such:
@PersistenceCapable
public class Deck {
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key _ID;

    @Persistent
    String _Name;

    @Persistent(defaultFetchGroup = "true", mappedBy = "_Parent")
    @Element(dependent = "true")
        private Set<Card> _Cards =  new HashSet<Card>();

    @Persistent
        private Set<String> _Tags = new HashSet<String>();


    @Persistent
    private KleioUser _Owner;

}

And finally, each card:

@PersistenceCapable
public class Card {
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key _ID;

   @Persistent
    private Text _Question;
    @Persistent
    private Text _Answer;
    @Persistent
    private Deck _Parent;
}

I've only run this on the dev server.  When I create a new user and
populate the corresponding decks and corresponding cards and then call
pm.makepersistent(user), everything looks fine and I can see all the
user, deck, and card entities in the development datastore.  However,
when I try to retrieve a user with the following query:

                Query query = _pm.newQuery(SpecificUser.class);
                query.setFilter("_UniqueIdentifier == TheUser");
                query.declareParameters("String TheUser");

            try {
                        List<SpecificUser> results = 
(List<SpecificUser>)query.execute(ID);

                        if(results.size() == 0)
                                return null;
                        else
                                return results.get(0);

            } finally {
                query.closeAll();
            }

I get the user just fine, and all the user's corresponding decks.  But
the decks have no cards.  "Touching" the deck's cards collection with
a .size() method doesn't load the cards, just returns 0, nor does
setting the cards to the default fetch group.  I also tried to set the
pm's fetchplan to -1, but that didn't have the desired effect either.

The weird thing is that if I persist the Deck without a parent user,
then I will get the deck back, along with all its cards, with no
problems.

I've tried a lot of other things too and I'm starting to run low on
ideas (and high on frustration), so any help would be appreciated.

Thanks,
Mike

-- 
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