引起原因:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:“字段列表”中的未知列“ purchased1_.DTYPE”

Sha*_*lam 1 java mysql hibernate hibernate-mapping

嗨,我在尝试获取定义的数据时遇到了一些问题,如下所示

购买的.java

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

reportable.java

public interface Reportable {

}
Run Code Online (Sandbox Code Playgroud)

而且我有另一个类约会.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;

}
Run Code Online (Sandbox Code Playgroud)

和实现预定的接口delivery.java就像

public interface Delivery {

    public long getId();

    public DeliveryStatus getDeliveryStatus();

}
Run Code Online (Sandbox Code Playgroud)

现在实际上当我试图查询像

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);
}
Run Code Online (Sandbox Code Playgroud)

当我尝试检查返回约会对象时,我喜欢对象调用异常,而在我的代码中,我想喜欢

约会.getId();

我越来越像错误

引起原因:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:“字段列表”中的未知列“ purchased1_.DTYPE”

从一天开始就为此苦苦挣扎,所以为什么我要面对这个问题,以及如何解决这个问题

San*_*mar 5

您错过@DiscriminatorColumn了Purchased.java