我有表ctl与表有两个关系:psr和psg。 此表与PK具有相同的名称:COD_FILEFE_S
public class Psr{
@Id
@Column(name = "COD_FILEFE_S")
private BigDecimal codFilefeS;
}
public class Psg{
@Id
@Column(name = "COD_FILEFE_S")
private BigDecimal codFilefeS;
}
可以用hibernate映射这个吗? 使用以下模型,我有org.hibernate.MappingException:实体映射中的重复列:
public class Ctl{
/** The cod filefe s. */
@ManyToOne(targetEntity = Psg.class)
@JoinColumn(name = "COD_FILEFE_S", referencedColumnName = "COD_FILEFE_S", nullable = false)
private BigDecimal codFilefeS;
/** The cod filefe s. */
@ManyToOne(targetEntity = Psr.class)
@JoinColumn(name = "COD_FILEFE_S", referencedColumnName = "COD_FILEFE_S", nullable = false)
private BigDecimal codFilefeSPert;
}
答案 0 :(得分:-1)
正如您提到的两列相同的名称,您收到此错误.. 更改第二个列的名称..
public class ctl{
/** The cod filefe s. */
@ManyToOne(targetEntity = Psg.class)
@JoinColumn(name = "COD_FILEFE_S", referencedColumnName = "COD_FILEFE_S", nullable = false)
private BigDecimal codFilefeS;
/** The cod filefe s. */
@ManyToOne(targetEntity = Psr.class)
@JoinColumn(name = "COD_FILEFE_S_PERT", referencedColumnName = "COD_FILEFE_S", nullable = false)
private BigDecimal codFilefeSPert;
}