不能将org.hibernate.mapping.Formula类强制转换为org.hibernate.mapping.Column

时间:2019-06-19 12:27:16

标签: java hibernate jpa

似乎@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;
}

0 个答案:

没有答案