传统db:JoinColumnsOrFormulas和compositeId以及继承

时间:2012-01-26 13:21:01

标签: hibernate playframework

我正在训练映射遗留数据库。

@Entity
public class ProcessPoint extends GenericModel {

    @Id
    @GeneratedValue
    @Column(name = "zkodid")
    public Long id;

    @ManyToOne
    @JoinColumnsOrFormulas({
        @JoinColumnOrFormula(column = @JoinColumn(name = "TELTXT", insertable = false, updatable = false, referencedColumnName = "id")),
        @JoinColumnOrFormula(formula = @JoinFormula(value = MeasurementLongName.TYP_TABLICY, referencedColumnName = "typ_tablicy"))
    })
    public MeasurementLongName measurementLongName;
    ...
}

MeasurementLongName

@Entity
@DiscriminatorValue(value=MeasurementLongName.TYP_TABLICY)
public class MeasurementLongName extends SystemName {
    public static final String TYP_TABLICY = "23";
}

@Entity
@Table(name = "BAZA_NAZW")
@Inheritance
@DiscriminatorColumn(name="typ_tablicy")

@org.hibernate.annotations.Filter(
      name = "limitByLang",
      condition="lang_id = :currentLang"
  )
@IdClass(SystemNameId.class)
public class SystemName extends GenericModel {

@Id
public Long id;

@Id
@Column(insertable = false, updatable = false)
public int typ_tablicy;

@Column(name = "opis")
public String description;

@Override
public String toString() {
    return description;
}

BAZA_NAZW:

@Entity
@Table(name = "BAZA_NAZW")
@Inheritance
@DiscriminatorColumn(name="typ_tablicy")

@org.hibernate.annotations.Filter(
  name = "limitByLang",
  condition="lang_id = :currentLang"
  )
@IdClass(SystemNameId.class)
public class SystemName extends GenericModel {

@Id
public Long id;

@Id
@Column(insertable = false, updatable = false)
public int typ_tablicy;

@Column(name = "opis")
public String description;

@Override
public String toString() {
    return description;
}

当我尝试进行查询时:

  List<ProcessPoint> processPoints = ProcessPoint.find("station", station).fetch();

我得到了:     已捕获到javax.persistence.PersistenceException,org.hibernate.HibernateException:SqlNode的文本未引用预期的列数

0 个答案:

没有答案