0

所以,我有一个带有自定义 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. 有什么好的和简单的解决方案吗?

4

1 回答 1

0

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

于 2013-02-11T13:48:46.280 回答