objectify-appengine - 嵌入式类 - 不是受支持的属性类型

发布于 2024-10-26 07:45:31 字数 1124 浏览 6 评论 0原文

我正在谷歌应用程序引擎上尝试objectify(版本2.2.3)嵌入类示例(wiki)。我收到此错误:

java.lang.IllegalArgumentException: one: com.mypkg.LevelOne is not a supported property type.
    at com.google.appengine.api.datastore.DataTypeUtils.checkSupportedSingleValue(DataTypeUtils.java:184)

我的代码与 Wiki 中的代码相同。控制器中的部分:

    EntityWithEmbedded ent = new EntityWithEmbedded();
    ent.one = new LevelOne();
    ent.one.foo = "Foo Value";
    ent.one.two = new LevelTwo();
    ent.one.two.bar = "Bar Value";

EntityWithEmbedded 类:

import javax.jdo.annotations.Embedded;
import javax.persistence.Entity;
import javax.persistence.Id;

@Entity
public class EntityWithEmbedded {
    @Id public Long id;
    @Embedded public LevelOne one;
    //getter & setters here
}

类 levelOne:

import javax.persistence.Embedded;
public class LevelOne {
    public String foo;
    public @Embedded LevelTwo two;
    //getter & setters here
}

类 LevelTwo:

public class LevelTwo {
    public String bar;
        //getter & setters here
}

所以这是我正在尝试的基本示例。关于缺少什么有什么想法吗?

I am trying out the objectify(version 2.2.3) embedded classes example (wiki) on google app engine. I am getting this error:

java.lang.IllegalArgumentException: one: com.mypkg.LevelOne is not a supported property type.
    at com.google.appengine.api.datastore.DataTypeUtils.checkSupportedSingleValue(DataTypeUtils.java:184)

The code I have is the same as the one in Wiki. The section in the controller:

    EntityWithEmbedded ent = new EntityWithEmbedded();
    ent.one = new LevelOne();
    ent.one.foo = "Foo Value";
    ent.one.two = new LevelTwo();
    ent.one.two.bar = "Bar Value";

The EntityWithEmbedded class:

import javax.jdo.annotations.Embedded;
import javax.persistence.Entity;
import javax.persistence.Id;

@Entity
public class EntityWithEmbedded {
    @Id public Long id;
    @Embedded public LevelOne one;
    //getter & setters here
}

Class levelOne:

import javax.persistence.Embedded;
public class LevelOne {
    public String foo;
    public @Embedded LevelTwo two;
    //getter & setters here
}

Class LevelTwo:

public class LevelTwo {
    public String bar;
        //getter & setters here
}

So it is the basic example that I am trying out. Any ideas on what is missing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

往事随风而去 2024-11-02 07:45:31

您在 EntityWithEmbedded 中使用了错误的 @Embedded 注释。

使用 javax.persistence.Embedded 而不是 javax.jdo.annotations.Embedded

You're using the wrong @Embedded annotation in EntityWithEmbedded.

Use javax.persistence.Embedded rather than javax.jdo.annotations.Embedded

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文