即使我没有设置分层映射,Hibernate似乎也会进入无限递归。 基本上我要做的是在父类中设置一对多映射,在子类中设置多对一
父类:
@XmlRootElement
@Entity
@Table(name = "ip")
public class FinalInvolvedParty {
private int ipId;
private List<IPIdentifier> iPIdentifierList;
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "ip_id", updatable = false)
public Integer getIpId() {
return ipId;
}
public void setIpId(int ipId) {
this.ipId = ipId;
}
@OneToMany
@Cascade(value = {org.hibernate.annotations.CascadeType.ALL})
@JoinColumn(name = "ip_id", nullable = false)
public List<IPIdentifier> getiPIdentifierList() {
return iPIdentifierList;
}
public void setiPIdentifierList(List<IPIdentifier> iPIdentifierList) {
this.iPIdentifierList = iPIdentifierList;
}
....
和儿童班:
@XmlRootElement
@Entity
@Table(name = "ip_identifier")
public class IPIdentifier {
private int ipIdentifierId;
private FinalInvolvedParty ipById;
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "ip_Identifier_Id", updatable = false)
public int getIpIdentifierId() {
return ipIdentifierId;
}
public void setIpIdentifierId(int ipIdentifierId) {
this.ipIdentifierId = ipIdentifierId;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "ip_id", referencedColumnName = "ip_id", nullable = false, insertable = false, updatable = false)
public FinalInvolvedParty getIpById() {
return ipById;
}
public void setIpById(FinalInvolvedParty ipById) {
this.ipById = ipById;
}
....
我的数据保持正确,但是当我获取数据时,Hibernate会进入无限递归
有人知道可能出现什么问题吗?