【问题标题】:Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'purchased1_.DTYPE' in 'field list'引起:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:“字段列表”中的未知列“purchased1_.DTYPE”
【发布时间】:2013-11-30 10:36:50
【问题描述】:

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

购买的.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();

}

现在实际上当我尝试像这样查询时

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);
}

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

appointment.getId();

我遇到了类似的错误

原因:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'purchased1_.DTYPE' in 'field list'

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

【问题讨论】:

    标签: java mysql hibernate hibernate-mapping


    【解决方案1】:

    您在购买的.java 中错过了@DiscriminatorColumn

    【讨论】:

    • 像魅力一样工作真的很明显我不明白我怎么错过了无论如何你的回答解决了我的问题非常感谢你的回答
    猜你喜欢
    • 2013-02-27
    • 2017-06-27
    • 2016-10-07
    • 2014-07-19
    • 2018-05-15
    • 2012-10-13
    • 1970-01-01
    • 2015-03-04
    • 2018-05-12
    相关资源
    最近更新 更多