objectify-appengine - 嵌入式类 - 不是受支持的属性类型 [英] objectify-appengine - Embedded class - not a supported property type

查看:132
本文介绍了objectify-appengine - 嵌入式类 - 不是受支持的属性类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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)

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

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";

EntityWithEmbedded类:

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:

Class levelOne:


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

Class LevelTwo:

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?

推荐答案

你使用了错误的 @Embedded c注释 EntityWithEmbedded

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

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

这篇关于objectify-appengine - 嵌入式类 - 不是受支持的属性类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆