开发者

Parent key of type encoded string?

开发者 https://www.devze.com 2022-12-28 19:24 出处:网络
How do we create a parent key which is an encoded string? Example: class Parent { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)

How do we create a parent key which is an encoded string? Example:

class Parent {

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

class Child {

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

    // In the doc examples, they have Key as the type here.
    @Persistent
    @Extension(vendorName="datanucleus", key="gae.parent-pk", value="true")
    private String mParentEncKey;
}

yeah I'm not sure how to make mParentEncKey an encoded string type, because the 'key' label is already being used? I would need something like?:

key="gae.parent-pk.encoded-pk"

not sur开发者_开发问答e - is that possible?

Thanks


I have found a solution for this, you can now map owned relations in a portable manner, check out blog.


This discussion says to just use gae.parent-pk - GAE will automatically use an encoded string value for a parent key field in Child.

https://groups.google.com/group/google-appengine-java/browse_thread/thread/43e38d0bc8a41bbd/0f0f86693330c1b2

0

精彩评论

暂无评论...
验证码 换一张
取 消