簡體   English   中英

如何使用bean arraylist到另一個帶有休眠注釋的bean中?

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

我想在另一個bean中使用一個bean arraylist作為字段。 而且我收到“ mappedBy引用未知目標實體屬性”錯誤。

我有兩個類1.日志2.日志,並且所有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;
}

mappingBy =“ executionid”錯誤。

此字段必須引用“屬性”。 這就是錯誤的意思。

它必須被映射為字段類別名稱而不是列名稱的mapBy =“ executionId”。

感謝@Guilherme Ribeiro開發人員,這是正確的答案

日志表;

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

日志表;

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM