后台打印的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是否为关键字啊。。。很明显你的表里面有没有 type 这个列是否是数字型, 可能是关键字,你改个名字试试表的type字段没有