Кажется, что @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;
}