0
我被這個錯誤消息卡住了,每次我想要添加與另一個實體類的ManytoOne關係時都會出現此錯誤消息。沒有爲此實體層次結構定義的ID
該類必須使用一致的訪問類型(字段或屬性)。沒有這個實體層次
定義ID這是我的實體交易
@Entity
@Table(name = "CustomerTransaction")
public class CustomerTransaction implements Serializable {//this is the line with the error message
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@ManyToOne //This generates the problem
@JoinColumns({
@JoinColumn(name = "CUS_ID", referencedColumnName = "IDCUSTOMER") })
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
private long transactionID;
@Temporal(TemporalType.TIMESTAMP)
private Date buyDate;
public Date getBuyDate() {
return buyDate;
}
public void setBuyDate(Date buyDate) {
this.buyDate = buyDate;
}
public long getTransactionID() {
return transactionID;
}
public void setTransactionID(long transactionID) {
this.transactionID = transactionID;
}
public String getCarYear() {
return carYear;
}
public void setCarYear(String carYear) {
this.carYear = carYear;
}
public Date getTransactionDate() {
return transactionDate;
}
public void setTransactionDate(Date transactionDate) {
this.transactionDate = transactionDate;
}
private String carYear;
@Temporal(TemporalType.TIMESTAMP)
private Date transactionDate;