>
> Hi Everyone,

I'm trying to get a many-to-many unowned relationship modeled using JPA and 
the appengine-datanucleus v2 plugin, but I can't get it work and all the 
examples I've found online are for JDO or else pre v2 of the plugin. Has 
anyone gotten manytomany or really any kind of unowned relationships to 
work using JPA and v2 of the datanucleus plugin? What would they look like? 
Here's the example I tried:

@Entity
public class This implements Serializable {
 
    @Id

    @GeneratedValue(strategy = GenerationType.IDENTITY) 

    private Key key;

    @ManyToMany

    private Set<That> someOfThat;

}

@Entity

public class That implements Serializable {

      @Id

      private String urlForThat;

}

If I create an instance of That, persist it, and then add it to 
this.getSomeOfThat().add(that); it throws 


Caused by: java.lang.IllegalArgumentException: Cannot parse: 
> http://somesite.org/wiki/index.php?title=Special:Recentchanges===
> at com.google.appengine.api.datastore.KeyFactory.stringToKey(
> KeyFactory.java:192)


Where that string is what I set as the id for That. The fact that it is 
using stringToKey makes me think that it is treating the urlForThat as an 
encoded string key instead of an un-encoded one, which would be what it 
would need if the relationship was owned I think?

The code that does this is something like this:
This this = em.find//get existing instance from entity manager
That t = new That();
t.setUrlForThat("http://somesite.org/wiki/index.php?title=Special:Recentchanges";);
em.persist(t);
this.getSomeOfThat().add(t);

The exception gets thrown at the last line there.

Any idea what I am doing wrong? Or is this just not possible? 

Thanks for the help!

Marc

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-appengine-java/-/sf53YvBYkRwJ.
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