Jpa 没有为此实体层次结构定义ID
每次我想添加与另一个实体类的多通关系时,都会出现此错误消息 该类必须使用一致的访问类型(字段或属性)。没有为此实体层次结构定义ID 这是我的实体交易Jpa 没有为此实体层次结构定义ID,jpa,Jpa,每次我想添加与另一个实体类的多通关系时,都会出现此错误消息 该类必须使用一致的访问类型(字段或属性)。没有为此实体层次结构定义ID 这是我的实体交易 @Entity @Table(name = "CustomerTransaction") public class CustomerTransaction implements Serializable {//this is the line with the error message @Id @GeneratedValue
@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;
JPA注释应该全部放在字段或访问器方法上。您已将
@Id
和@GeneratedValue
注释放置在字段(专用长Id
)上,但将@manytone
和@JoinColumns
放置在getter(公共长getId()
)上。将后者也移动到场地上