【问题标题】:Objectify v5: Profile is not a supported property typeObjectify v5:配置文件不是受支持的属性类型
【发布时间】:2015-03-20 07:02:08
【问题描述】:

我一直在关注 Objectify 的 v5 教程,我有两个类,其中一个嵌入到另一个中:

@Entity
public class User {

    @Id Long id;

    private Profile profile;

    private User(){}

    /**
     * Creates a new instance of user.
     * @param id Id of the user. If <code>null</code>, id will be automatically generated.
     * @param profile profile of the user.
     */
    public User(final Long id, @NotNull final Profile profile){

        this.id = id;
        this.profile = profile;

    }
}
public class Profile {

    private String firstName;

    private String middleName;

    private String lastName;

    private Date birthDate;

    private Profile(){}

    public Profile(@NotNull final String firstName, @NotNull final String lastName ){

        this.firstName = firstName;
        this.lastName = lastName;

    }
}

为了测试这段代码,我写了如下端点:

@ApiMethod(name = "user.create", httpMethod = "post")
    public User createUser(@Named("id") Long id, @Named("fn") String firstName, @Named("ln") String lastName){

        Profile profile = new Profile(firstName,lastName);
        User user = new User(id,profile);

        ofy().save().entity(user).now();

        return user;
    }

但是当我执行这个请求时,我得到一个错误:

配置文件不是受支持的属性类型。

我不明白我为什么会遇到这个问题,因为据我所知,我的情况类似于教程中给出的汽车/发动机示例。

感谢您的帮助。

【问题讨论】:

    标签: java google-app-engine google-cloud-endpoints objectify


    【解决方案1】:

    我之前一直在使用 Objectify v3。我将 pom.xml 中的版本更新为 5.1,但错误仍然存​​在。然而,一旦我清理了项目,问题就解决了。

    【讨论】:

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