日期:2014-05-17  浏览次数:20827 次

大神们开始找错啦!!org.hibernate.exception.SQLGrammarException: could not execute query
后台打印的hql语句:
Hibernate: 
    select
        dishes0_.id as id2_,
        dishes0_.DishesName as DishesName2_,
        dishes0_.DishesType as DishesType2_,
        dishes0_.price as price2_,
        dishes0_.type as type2_ 
    from
        myshop.DISHESNAME dishes0_
实现DAO:

public List<Dishes> getAll() {
try {
String hql="from Dishes";
Query query = session.createQuery(hql);
return query.list();
} catch (Exception e) {
e.printStackTrace();
return null;
}
}

hibernate配置文件:

<hibernate-mapping>
    <class name="com.shop.bean.Dishes" table="DISHESNAME" schema="myshop">
        <id name="id" type="java.lang.Integer">
            <column name="id" precision="20" scale="0" />
            <!-- <generator class="sequence"> 
       <param name="sequence">Sequence_Order</param> 
    </generator> -->
    <generator class="identity" /> 
        </id>
        
        <property name="dishesName" type="java.lang.String">
            <column name="DishesName" />
        </property>
        
        <property name="dishesType" type="java.lang.Integer">
            <column name="DishesType" />
        </property>
        
        <property name="price" type="java.lang.Double">
            <column name="price" />
        </property>
        
        <property name="type" type="java.lang.Integer">
            <column name="type" />
        </property>
    </class>
</hibernate-mapping>


------解决方案--------------------
你实际表有type列么,在sql客户端上执行hql有语法错误么