引起:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:'字段列表'中的未知列'created1_.DTYPE'

时间:2013-11-17 06:59:10

标签: java mysql hibernate hibernate-mapping

我正面临一些问题,而我正在尝试获取我的架构定义的数据如下

purchased.java

@SuppressWarnings("serial")
@Entity
@Table(name="purchased_listing")
@DiscriminatorValue(value="purchased")
public abstract class Purchased extends BaseDo implements Reportable {
     public Purchased() {
    super();
}
    //some implementation
}

reportable.java

public interface Reportable {

}

并且我有另一个类约会.java喜欢和我正在映射购买多个到一个映射,如下面

appointment.java

@SuppressWarnings("serial")
@Entity
@Table(name="appointments")
@DiscriminatorColumn(name="class_code")
@DiscriminatorValue("appointment")
public class Appointment extends BaseDo implements Delivery {
        public Appointment() {

    }

        @ManyToOne
    @JoinColumn(name="purchased_id")
    private Purchased purchased;

}

和实现约会的接口delivery.java就像

public interface Delivery {

    public long getId();

    public DeliveryStatus getDeliveryStatus();

}

现在实际上当iam尝试查询时

public Appointment getAppointmentInfoByAppointmentId(long id) throws DaoException {
    Iterator<Appointment> itr = getHibernateTemplate().iterate(
            "from Appointment app where app.id = ?", id);
    if (itr.hasNext()) {
        return itr.next();
    }
    throw new DaoException("No appointment found with id = " + id);
}

当iam尝试检查返回约会对象时,Iam变得像 objectinvocation exception ,并且在我的代码中,当我试图喜欢

appointment.getId();

我得到的错误就像

引起:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:'字段列表'中的未知列'created1_.DTYPE'

为此而苦苦挣扎,因为有一天无法得到解决方案,所以我为什么要面对这个问题以及如何解决这个问题

1 个答案:

答案 0 :(得分:5)

您错过了purchase.java中的@DiscriminatorColumn