Looks like you're running into
http://code.google.com/p/datanucleus-appengine/issues/detail?id=126

This is a lousy bug report, and I can say that without fear of offending
anyone because I'm responsible for it.

The fix will be available in the next SDK (currently working its way through
QA).  In the meantime the workaround is to use a Key primary key on the
parent object.

Sorry for the trouble,
Max

On Wed, Nov 11, 2009 at 10:23 PM, Peter Recore <peterrec...@gmail.com>wrote:

> Here's the stacktrace I get when calling remove on a list containing
> child elements of a one to many owned relationship.
>
> java.lang.ClassCastException: java.lang.Long cannot be cast to
> java.lang.String
>        at
> org.datanucleus.store.appengine.DatastoreFKListStoreSpecialization.removeAt
> (DatastoreFKListStoreSpecialization.java:155)
>        at org.datanucleus.store.mapped.scostore.FKListStore.removeAt
> (FKListStore.java:525)
>        at org.datanucleus.store.mapped.scostore.AbstractListStore.remove
> (AbstractListStore.java:318)
>        at org.datanucleus.sco.backed.List.remove(List.java:907)
>        at usabletek.plyus.server.TestEntity.demonstrateProblem
> (TestEntity.java:31)
>
>
> I'm trying to figure out if I'm not allowed to use Longs as primary
> keys, or if this is a bug, or if I'm doing something else wrong with
> the relationship.
> Here's as minimal an example as I can come up with:
>
> @PersistenceCapable(identityType = IdentityType.APPLICATION)
> public class TestEntity {
>        @PrimaryKey
>        @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
>        private Long id;
>
>        @Persistent(mappedBy = "parent")
>        private List<TestChildEntity> childEntities;
>
>
>        public List<TestChildEntity> getChildEntities() {
>                return childEntities;
>        }
>
>        public static void demonstrateProblem(){
>                PersistenceManager pm = PMF.get().getPersistenceManager();
>                TestEntity te = new TestEntity();
>                pm.makePersistent(te);
>                te.getChildEntities().add(new TestChildEntity("a"));
>                te.getChildEntities().remove(0);
>                pm.close();
>        }
> }
>
> @PersistenceCapable(identityType = IdentityType.APPLICATION)
> public class TestChildEntity {
>        @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
>        private TestEntity parent;
>
>
>        public TestChildEntity(String k){
>                this.keyName = k;
>        }
> }
>
> --
>
> 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<google-appengine-java%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=.
>
>
>

--

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


Reply via email to