我正在尝试在我的一个实体类中使用json强制引用。该实体与另一个具有复合主键的实体具有多对多关系。
我在A类中
/**
* @return the classB
*/
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "SEC_ID", referencedColumnName = "PT_ID", updatable = false, insertable = false)
@JsonBackReference
public classB getClassB() {
return classB;
}
ClassB
/**
* @return the pxxId
*/
@EmbeddedId
public PxxId getPxxId() {
return pxxId;
}
嵌入式ID
@Embeddable
public class PxxId implements Serializable {
/**
*
*/
private static final long serialVersionUID = 7080557675086058087L;
private Long taId;
private Long maId;
/**
* @return the id
*/
@Column(name = "PT_ID", nullable = false, length = 20)
public Long getTaId() {
return tabId;
}
/**
* @param id
* the id to set
*/
public void setTaId(Long id) {
this.taId = id;
}
/**
* @return the maId
*/
@Column(name = "MA_ID", length = 20, nullable = false)
public Long getMaId() {
return maId;
}
/**
* @param mId
* the maId to set
*/
public void setMaId(Long maId) {
this.maId = maId;
}
}
我尝试了上述操作,但出现类似
的错误... 41 more
Caused by: org.hibernate.AnnotationException: referencedColumnNames(PT_ID) of com.citi.aml.npa.domain.ClassA.classB referencing com.citi.aml.npa.domain.ClassB not mapped to a single property
at org.hibernate.cfg.BinderHelper.createSyntheticPropertyReference(BinderHelper.java:336)
at org.hibernate.cfg.ToOneFkSecondPass.doSecondPass(ToOneFkSecondPass.java:116)
at org.hibernate.cfg.Configuration.processEndOfQueue(Configuration.java:1557)
at org.hibernate.cfg.Configuration.processFkSecondPassInOrder(Configuration.java:1478)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1386)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1781)
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:96)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)
... 48 more
有人可以帮我吗?