后台打印的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>
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>
解决方案 »
- 求救jsp:usebean的问题!
- prepareStatement 中的sql语句 为什么不能用like %?% 模糊查询呢?
- MyEclipse 6连接不上sql2000急
- 关于WEB上传文件的问题,急急急!!!解决给分 ,不够可加份
- 求JSP连接sql server 2000的demo程序
- javamail的问题,如何粘贴多个附件?就像Yahoo,网易那样?!
- java.lang.IllegalStateException 报错信息。怎么办?
- 为什么文件不能写入?
- 如何在不需要端口号的前提下访问jsp
- java web项目 下载功能 浏览器无显示
- JSP页面显示天气,webservice或引用链接?
- 怎样区别本地磁盘中的系统文件和普通文件
报的错:
org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:2223)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at com.shop.dao.impl.DishesDaoImpl.getAll(DishesDaoImpl.java:63)
at com.shop.biz.impl.DishesBizImpl.getAll(DishesBizImpl.java:42)
at com.shop.action.DishesAction.dishesSelect(DishesAction.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:404)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:267)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:229)
at com.shop.util.LoginInterceptor.intercept(LoginInterceptor.java:24)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
又或者type是否为关键字啊