似乎@MapsId
和@JoinFormula
不能一起工作。
我有例外
class org.hibernate.mapping.Formula cannot be cast to class org.hibernate.mapping.Column
用于以下JPA代码
@Entity
@Table(name = "HCOMP")
public class Hcomp implements Serializable {
private static final long serialVersionUID = 1L;
@MapsId("hcndid")
@ManyToOne
@JoinColumnsOrFormulas({
@JoinColumnOrFormula(formula = @JoinFormula(value = "(SELECT a.hcndagn FROM Hcond a WHERE a.hcndid = hcndid AND a.hcndagn >= hcompPK.hcndagnfrom AND a.hcndagn <= hcompPK.hcndagnto AND a.hcndavails = 'A')", referencedColumnName = "hcndagn")),
@JoinColumnOrFormula(column = @JoinColumn(name = "hcndid", referencedColumnName = "hcndid", insertable = false, updatable = false)) })
private Hcond hcond;
@EmbeddedId
HcompPK hcompPK;
}