【问题标题】:Objectify - @Embedded Error saving XXX is not a supported property typeObjectify - @Embedded Error 保存 XXX 不是受支持的属性类型
【发布时间】: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


【解决方案1】:

真丢脸。我将 objectify 版本切换到 5.0.5 但没有再次清理/打包。似乎目标 appengine-devserver 没有更新 Maven 依赖项。所以我仍在使用 4.x 版。为什么 4.x 不工作我不知道。 使用 5.0.5 一切正常。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-16
    • 2019-03-17
    • 1970-01-01
    • 2018-12-24
    • 2014-03-21
    相关资源
    最近更新 更多