hibernate中注解manytoone使用复合主键怎样实现
展开全部
你的KeyValuePK里面的内容,直接添加就可以!
public class BillTbodyPK implements Serializable {
private static final long serialVersionUID = -1190986010439330142L;
private SingleInfo mid;
private BillHeadModel billId;
public BillTbodyPK() {
}
// setter getter
@ManyToOne(fetch = FetchType.LAZY,cascade = { CascadeType.ALL })
@JoinColumn(name = "mid", referencedColumnName = "mid", unique = false, nullable = false, insertable = false, updatable = false)
@NotFound(action = NotFoundAction.IGNORE)
@Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
public SingleInfo getMid() {
return mid;
}
public void setMid(SingleInfo mid) {
this.mid = mid;
}
@ManyToOne
@JoinColumn(name = "dj_id", nullable = false)
@NotFound(action = NotFoundAction.IGNORE)
@Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
public BillHeadModel getBillId() {
return billId;
}
public class BillTbodyPK implements Serializable {
private static final long serialVersionUID = -1190986010439330142L;
private SingleInfo mid;
private BillHeadModel billId;
public BillTbodyPK() {
}
// setter getter
@ManyToOne(fetch = FetchType.LAZY,cascade = { CascadeType.ALL })
@JoinColumn(name = "mid", referencedColumnName = "mid", unique = false, nullable = false, insertable = false, updatable = false)
@NotFound(action = NotFoundAction.IGNORE)
@Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
public SingleInfo getMid() {
return mid;
}
public void setMid(SingleInfo mid) {
this.mid = mid;
}
@ManyToOne
@JoinColumn(name = "dj_id", nullable = false)
@NotFound(action = NotFoundAction.IGNORE)
@Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
public BillHeadModel getBillId() {
return billId;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询