[appengine-java] Re: Unowned relations JPA examples for datanucleus plugin v2
Thanks datanucleus! I thought about the @Unowned annotation but I didn't have the datanucleus-appengine-2.0.0-RC2.jar in my eclipse build path... Unfortunately I'm not out of the woods yet. I downloaded and built the jars from the the svn trunk, and I modified my entities to match exactly the mapping defined in the JPAManyToManyTest.java from the unit tests in that project, but when I run my application locally via eclipse, I get this exception: Caused by: com.google.appengine.datanucleus.EntityUtils $ChildWithoutParentException: Detected attempt to establish This(2) as the parent of That(3) but the entity identified by That(3) has already been persisted without a parent. A parent cannot be established or changed once an object has been persisted. at com.google.appengine.datanucleus.EntityUtils.checkParentage(EntityUtils.java: 577) at com.google.appengine.datanucleus.scostore.FKSetStore.add(FKSetStore.java: 171) at org.datanucleus.store.types.sco.backed.Set.add(Set.java:562) Seems like at runtime the @Unowned is being ignored? Not sure if this is a classpath issue or maybe something to do with running it locally in Eclipse using the GAE plugin? I'm not really sure what else to look for at this point so if you have any ideas for anything else I can check I'd really appreciate it. THanks again for the response... On Jan 22, 11:11 am, datanucleus andy_jeffer...@yahoo.com wrote: To make a relation unowned (in v2) you mark (both sides if bidirectional) as @Unowned Unowned M-N work fine with SVN trunk code, though there may have been some things incomplete in RC versions -- 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-java@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.
[appengine-java] Unowned relations JPA examples for datanucleus plugin v2
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 SetThat 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 google-appengine-java@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.