我正在谷歌应用引擎上尝试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 }
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 }
所以这是我尝试的基本例子。关于什么缺失的任何想法?
答案 0 :(得分:5)
您在@Embedded
中使用了错误的EntityWithEmbedded
注释。
使用javax.persistence.Embedded
而不是javax.jdo.annotations.Embedded