App Engine JDO Persistent类从com.google.appengine.api.datastore.Key迁移到Long

时间:2021-07-12 23:13:14

I've been working to get an app that runs on GAE to support other platforms like a single instance of a Jetty Server.

我一直在努力获得一个在GAE上运行的应用程序,以支持其他平台,例如Jetty Server的单个实例。

A Persistent JDO class with a primary key defined like this:

一个持久的JDO类,其主键定义如下:

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "false")
@Inheritance(strategy = InheritanceStrategy.SUBCLASS_TABLE)
public abstract class Foo implements Bar {


    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    protected Key key;

The key is a com.google.appengine.api.datastore.Key;

关键是com.google.appengine.api.datastore.Key;

Short of doing a data migration, is it possible to somehow convert this field to a Long or something that's supported in other platforms like mySQL and not needing to use an app-engine library?

没有进行数据迁移,是否有可能以某种方式将此字段转换为Long或其他平台(如mySQL)支持的内容,而不需要使用app-engine库?

1 个解决方案

#1


0  

ok looks like it's possible to just convert it to a string and i'm good to go.

好吧看起来可以将它转换为字符串,我很高兴。

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "false")
@Inheritance(strategy = InheritanceStrategy.SUBCLASS_TABLE)
public abstract class EntityStore implements Entity {


    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    protected String key;

#1


0  

ok looks like it's possible to just convert it to a string and i'm good to go.

好吧看起来可以将它转换为字符串,我很高兴。

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "false")
@Inheritance(strategy = InheritanceStrategy.SUBCLASS_TABLE)
public abstract class EntityStore implements Entity {


    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    protected String key;