The error message detail is 'Object with
id "agp0cnV4bWFwcGVychkLEgdUd2VldGVyIgxrZXlkb3NhdHJ1Y2sM" is managed
by a different Object Manager.'
----------------------------------------

Looks like you are using more than one PersistenceManager (PM)
instance on the same object. Are you closing PM instances immediately
after use? I use the following pattern for PMs:

PersistenceManagerFactory pmf =
 DataExchange.getPersistenceManagerFactory();
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();

try
{
        tx.begin();

        // Do persistence stuff here...

        tx.commit();
}
finally
{
        try
        {
                if (tx.isActive())    // Because of an exception, say
                        tx.rollback();
        }
        finally
        {
                pm.close();
        }
}


@Order(extensions = @Extension(vendorName="datanucleus", key="list-
ordering", value="key ASC"))
----------------------------------------
You have changed the Truck PK field name, so you should replace "key
ASC" with "keyName ASC".


Enjoy?


On Sep 27, 10:12 pm, culov <cul...@gmail.com> wrote:
> Ian-
>
> Thanks a lot for your reply. The error message detail is 'Object with
> id "agp0cnV4bWFwcGVychkLEgdUd2VldGVyIgxrZXlkb3NhdHJ1Y2sM" is managed
> by a different Object Manager.'
>
> The objects aren't being handled by any other method except the
> addTrucks method in my DAO.  They are never added to the datastore.
> I've changed the code around a bit.  I'm now assigning keys using a
> unique id.  Tweeter now looks like...
>
>             @PrimaryKey
>             @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
>             @Extension(vendorName="datanucleus", key="gae.encoded-pk",
> value="true")
>             private String encodedKey;
>                 @Persistent
>                 @Extension(vendorName="datanucleus", key="gae.pk-name",
> value="true")
>                 private String keyName;
>                   ....
>                 @Persistent(mappedBy = "tweeter")
>                 @Order(extensions = @Extension(vendorName="datanucleus", 
> key="list-
> ordering", value="key ASC"))
>                 private List<Truck> trucks;
>
> and Truck:
>         @PrimaryKey
>     @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
>     @Extension(vendorName="datanucleus", key="gae.encoded-pk",
> value="true")
>     private String encodedKey;
>         @Persistent
>         @Extension(vendorName="datanucleus", key="gae.pk-name", value="true")
>         private String keyName;
> ....
>         @Persistent(dependent = "true")
>         private Tweeter tweeter;
>
> I have a feeling that I'm just not modelling the situation correctly.
> The case would more accurately be defined as N-1, because I will never
> access the List of Trucks stored in the Tweeter object.... I only want
> to access the Tweeter object stored in each truck.  It really seems
> like it should be very simple.
>
> Thanks alot!
> On Sep 27, 1:18 am, Ian Marshall <ianmarshall...@gmail.com> wrote:
>
> > Two things....
>
> > 1.  More importantly, what is the detail of your
> > javax.jdo.JDOUserException, and what is your code that is associated
> > with this exception?
>
> > 2.  I personally use bi-directional relationships between parent and
> > children. So in your case, you could add to your Tweeter class:
>
> >   @Persistent(mappedBy="tweeter")
> >   @Element(dependent="true")
> >   @Order(extensions = @Extension(vendorName="datanucleus", key="list-
> > ordering", value="key ASC"))
> >   private ArrayList<Truck> liTrucks = new ArrayList<Truck>();
>
> > but you might want to omit the "@Element" line.
>
> > On Sep 26, 11:07 pm, culov <cul...@gmail.com> wrote:
>
> > > I'm looking to tighten up some of my server-side code, but I'm having
> > > trouble properly establishing the relationship between entities.
> > > Before, I was using unencoded Strings as keys, but after reading the
> > > documentation here, I've changed them to encoded app-generated
> > > Strings.
>
> > > I have two Entities, Trucks and Tweeters. What I'd like is an
> > > accessible Tweeter inside every Truck. Every truck has to have a
> > > Tweeter associated with it (there may be many Trucks with the same
> > > Tweeter), but a Tweeter may have no Trucks. Thus, the Tweeter should
> > > be the parent, and the Truck the child. I'm having lots of trouble
> > > persisting the classes in the datastore and I'm hoping someone can
> > > look over how I created the classes and detect my errors. Currently im
> > > getting a javax.jdo.JDOUserException. When I try to persist a Truck
> > > object. Here's the relevant portion of my child class, Truck:
>
> > > @PrimaryKey
> > > @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
> > > @Extension(vendorName="datanucleus", key="gae.encoded-pk",
> > > value="true")
> > > private String key;
> > > ....
> > > @Persistent(defaultFetchGroup = "true")
> > > private Tweeter tweeter;
> > > and the parent, Tweeter:
>
> > > @PrimaryKey
> > > @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
> > > @Extension(vendorName="datanucleus", key="gae.encoded-pk",
> > > value="true")
> > > private String key;
> > > I never set any of the keys anywhere, and based on the logs, the keys
> > > are being set as they should be. I think there must be a critical
> > > misunderstanding of the relationship on my part thats leading me to
> > > see an error regardless of what I try. I know I can use
> > > com.google.appengine.api.datastore.Key, but my classes are also used
> > > client-side by GWT, so I can't import the Key class from the GAE
> > > library.
>
> > > Thanks so much for the help!
>
>

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