objectify-appengine - 嵌入式类 - 不是受支持的属性类型
我正在谷歌应用程序引擎上尝试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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您在
EntityWithEmbedded
中使用了错误的@Embedded
注释。使用 javax.persistence.Embedded 而不是 javax.jdo.annotations.Embedded
You're using the wrong
@Embedded
annotation inEntityWithEmbedded
.Use
javax.persistence.Embedded
rather thanjavax.jdo.annotations.Embedded