播放1.2.5 - 使用自定义ID加载初始数据

时间:2013-02-11 12:49:47

标签: playframework yaml

所以,我有一个带有自定义ID的模型,如下所示:

@Entity
public class SomeModel extends Model {

    @Id
    @Unique
    @Required
    public String myOwnId;

    @Required
    public String someOtherField;

    public SomeModel(final String myOwnId, final String someOtherField) {
        this.myOwnId = myOwnId;
        this.someOtherField = someOtherField;
    }

} 

我有一个initial-data.yml文件,如下所示:

SomeModel(myModel):
  myOwnId: "someID"
  someOtherField: "some value here"

然而,这不起作用:RuntimeException occured : Cannot load fixture initial-data.yml: org.hibernate.PropertyAccessException: could not set a field value by reflection setter of models.SomeModel.id。对此有什么好的和简单的解决方案?

1 个答案:

答案 0 :(得分:0)

好的,我的不好,它确实有效,但是,你必须扩展GenericModel,而不是Model与你的模型类。