objectify-appengine - Embedded class - not a supported property type

夙愿已清 提交于 2019-12-08 02:27:04

问题


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?


回答1:


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

Use javax.persistence.Embedded rather than javax.jdo.annotations.Embedded



来源:https://stackoverflow.com/questions/5428571/objectify-appengine-embedded-class-not-a-supported-property-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!