Same thing, but...

I tried wrapping both the initial makepersistent() call and then the
query in transactions, without changing anything else:

I get this, which I hope is related to my original issue:

javax.jdo.JDOFatalUserException: Illegal argument
NestedThrowables:
java.lang.IllegalArgumentException: can't operate on multiple entity
groups in a single transaction. found both Element {
  type: "GoogleAccountsUser " //This is the specific subclass of User
  id: 11
}
 and Element {
  type: "Deck"
  name: "_8ad07638-b233-4fef-9a7f-1cfbad4eaab3"
}

Now why would it think that decks and users are in different entity
groups...


On Mar 7, 3:05 pm, Toby <toby.ro...@gmail.com> wrote:
> Okay, I see. In my case it is a List not a Set ... but I think that
> really makes no difference.
> What I think is strange is that you initialize the fields:
>     @Persistent(defaultFetchGroup = "true", mappedBy = "_Parent")
>     @Element(dependent = "true")
>         private Set<Card> _Cards =  new HashSet<Card>();
>
> maybe that causes the _Cards to be reinitialized when the Entity is
> deserialized. Can you try to remove that?
>
> Cheers,
> Toby
>
> On Mar 7, 2:19 pm, tempy <fay...@gmail.com> wrote:
>
>
>
> > Thanks for the suggestion...
>
> > I did try that exact code and sad to say it didn't help, just returned
> > a 0-size collection.  I'm still trying to figure this out...
>
> > On Mar 7, 10:58 am, Toby <toby.ro...@gmail.com> wrote:
>
> > > Hello Mike,
>
> > > have you tried touching them before you close the query?
> > > I had similar problem and only solved it by calling the getter for the
> > > owned collection before detaching the results.
>
> > >  if (results.iterator().hasNext()) {
> > >                     for (Product fp : results) {
> > >                         //this is to force the collections to be detached
> > >                         fp.getItems();
> > >                     }
> > >                     return pm.detachCopyAll(results);
> > > ...
>
> > > I found no better way to do that. I actually started managing
> > > relationships by hand now because you have more control and more
> > > performance especially if you do not always need the child
> > > collections.
>
> > > But maybe there is also a way to trigger that through an annotation.
>
> > > Cheers,
> > > Toby
>
> > > On Mar 7, 1:46 am, tempy <fay...@gmail.com> wrote:
>
> > > > 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