【发布时间】:2014-10-08 12:52:17
【问题描述】:
当尝试使用@Embedded 类保存实体时,Objectify 抛出异常(ObjectifyTestDummy 已注册):
com.googlecode.objectify.SaveException:保存 test.ObjectifyTestDummy@2485b739 时出错:内部:test.ObjectifyInnerTest 不是受支持的属性类型。
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;
import javax.persistence.Embedded;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
@Entity
public class ObjectifyTestDummy {
@Id
@javax.persistence.Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Embedded
private ObjectifyInnerTest inner;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public ObjectifyInnerTest getInner() {
return inner;
}
public void setInner(ObjectifyInnerTest inner) {
this.inner = inner;
}
}
简单地说:
public class ObjectifyInnerTest {
}
怎么了?
【问题讨论】:
-
看起来您将 Objectify
@Entity与 Java 持久性@Embedded注释混合在一起。您使用的是 Objectify 4 还是 5?code.google.com/p/objectify-appengine/wiki/… -
这是故意的。我的代码中有一个用于在 jpa 和 objectify 之间切换的开关。所以两个版本都应该工作。我尝试了版本 4 和 5。即使我省略了 jpa 注释,它也不起作用。
标签: google-app-engine objectify