如何将bean arraylist 用于另一个带有hibernate 注释的bean?

How to use bean arraylist into the another bean with hibernate annotation?

我想将一个bean arraylist 用作另一个bean 的字段。我得到了“mappedBy reference an unknown target entity 属性” 错误。

我有两个 class 1. Logs 2. Log 并且所有 Logs 元素都比 Log 多了一个。 log.executionid可以是多条记录,但所有logs.executionid必须不同

@Entity
@Table(name = "t_logs")
public class Logs {

@Id
@Column(name = "executionid")
private String executionId;

@Column(name = "sentdate")
@Temporal(TemporalType.TIMESTAMP)
private Date sendDate;

@Column(name = "exceptionmessage")
private String exceptionMessage;

@OneToMany(mappedBy = "executionid", cascade = CascadeType.ALL)
private List<Log> loglist;
}



@Entity
@Table(name = "t_log")
public class Log {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private long id;

@Column(name = "executionid")
private String executionId;

@Column(name = "startdate")
@Temporal(TemporalType.TIMESTAMP)
private Date startDate;

@Column(name = "enddate")
@Temporal(TemporalType.TIMESTAMP)
private Date endDate;
}

mappedBy = "executionid" 是错误的。

此字段必须引用 "property"。这就是错误所说的。

必须mappedBy = "executionId",字段名class而不是列名

感谢@Guilherme Ribeiro Developer

,这是正确的答案

日志table;

    @OneToMany(mappedBy = "logs", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    private List<Log> loglist;

日志table;

    @ManyToOne
    @JoinColumn(name = "executionid")
    private Logs logs;