views:

13

answers:

0

Hi,

Having a problem using a class with an unencoded String key as an entity parent:

class Farm {
    @PriamryKey
    private String name;
}

class Cow {
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    @Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true")
    private String k;

    @Persistent
    @Extension(vendorName="datanucleus", key="gae.parent-pk", value="true")
    private String kparent;
}

...

Cow cow = new Cow();
cow.kparent = "myfarm"; // "myfarm" is unique pk of a Farm instance.
pm.makePersistent(cow);

Attempt was made to set parent to myfarm but this cannot be converted into a Key. at org.datanucleus.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:354)

In other words, I have a farm with a unique name, and I want to add a Cow to its entity group. I know the name of the farm it belongs to, but I want to generate a unique primary key for the cow itself. This works ok if the primary key of the Farm is an encoded key or just a regular Key.

Thanks