Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jpa 使用OneToMany注释引发异常_Jpa_Playframework_Ebean - Fatal编程技术网

Jpa 使用OneToMany注释引发异常

Jpa 使用OneToMany注释引发异常,jpa,playframework,ebean,Jpa,Playframework,Ebean,在使用EBean ORM的Play 2.0应用程序中,我有以下类: @Entity public class User extends Model { @Id public Long id; @Constraints.Required public String someString; @OneToMany(mappedBy="user", cascade=CascadeType.REMOVE) @OrderBy("index") p

在使用EBean ORM的Play 2.0应用程序中,我有以下类:

@Entity
public class User extends Model {

    @Id
    public Long id;

    @Constraints.Required
    public String someString;

    @OneToMany(mappedBy="user", cascade=CascadeType.REMOVE)
    @OrderBy("index")
    public List<UserImage> userImages = new ArrayList<UserImage>();
}

我做错了什么?为什么EBean不理解我的注释?

我想你错过了
UserImage类上的
@Entity
注释:

@Entity
public class UserImage extends Model {
    @Id
    public long id;

    @Constraints.Min(0)
    public int index;

    @Column(name="user_id")
    @ManyToOne
    public User user;

    //...
}

您是否在UserImage类上设置了
@Entity
注释(它没有显示在示例代码中)?没有,没有。这就是解决办法。啊。谢谢
@Entity
public class UserImage extends Model {
    @Id
    public long id;

    @Constraints.Min(0)
    public int index;

    @Column(name="user_id")
    @ManyToOne
    public User user;

    //...
}