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