检查一下 session.createQuery(sql)中的sql语句有没有写对啊。
解决方案 »
- ss整合,创建action时,不会交给spring创建?
- 请问谁有普元EOS5.3的视频教程及搭建的具体视频~我想学习
- hibernate中锁的问题
- 求救(关于struts动态表单验证的问题)
- 高薪诚聘JAVA开发和测试工程师
- 大姐请弟弟妹妹们帮忙了!用最简单的语言解释什么是javabean,EJB,STRUTS,JAVABEAN,JSP/Servlet,MVC分别是什么,之间的相互关系。还有从
- 请问用JSP如何获取一个网站的内容?有相关的JAR包吗?
- 小弟的毕业设计是web service集成.net和j2ee应用 ,请大侠给点意见
- 在weblogic7中用jsp通过local接口访问ejb的问题
- spring json gzip
- 请教几个action的问题,这样做有什么缺点?
- 配置pet store出问题
"select Vipdata from com.xiebing.hibernate.Vipdata Vipdata order by Vipdata.vipname");
这个别名不对,跟原名是一样的
message description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: net.sf.hibernate.exception.SQLGrammarException: Could not execute query
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause java.lang.RuntimeException: net.sf.hibernate.exception.SQLGrammarException: Could not execute query
com.xiebing.hibernate.VipService.getVipdataList(VipService.java:101)
org.apache.jsp.AddVipData_jsp._jspService(org.apache.jsp.AddVipData_jsp:134)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.4 logs.
import java.util.List;import net.sf.hibernate.HibernateException;import net.sf.hibernate.ObjectNotFoundException;import net.sf.hibernate.Query;import net.sf.hibernate.Session;import com.xiebing.hibernate.Vipdata;
/**
* @author Administrator
*
* TODO 要更改此生成的类型注释的模板,请转至
* 窗口 - 首选项 - Java - 代码样式 - 代码模板
*/
public class VipService {
private static VipService instance = null; private VipService() { } /** * 得到VipService的单态实例 * @return <code>VipService</code> singleton. */ public static synchronized VipService getInstance() { if (instance == null) { instance = new VipService(); } return instance; }
/** * 得到所有的记录 * * @return 记录的列表 */ public List getVipdataList() { Session session = null; try { session = SessionFactory.currentSession(); //创建一条HQL查询 Query query = session.createQuery( "select Vipdata from com.xiebing.hibernate.Vipdata Vipdata order by Vipdata.vipname"); return query.list();// } catch (HibernateException e) { System.err.println("Hibernate Exception" + e.getMessage()); throw new RuntimeException(e); } finally { if (session != null) { try { session.close(); } catch (HibernateException e) { System.err.println("Hibernate Exception" + e.getMessage()); throw new RuntimeException(e); } } } }
}
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd"><!-- DO NOT EDIT: This is a generated file that is synchronized -->
<!-- by MyEclipse Hibernate tool integration. -->
<hibernate-configuration> <session-factory>
<!-- properties -->
<property name="connection.username">sa</property>
<property name="connection.url">jdbc:odbc:t</property>
<property name="dialect">net.sf.hibernate.dialect.SQLServerDialect</property>
<property name="connection.password">123</property>
<property name="connection.driver_class">sun.jdbc.odbc.JdbcOdbcDriver</property> <!-- mapping files -->
<mapping resource="com/xiebing/hibernate/Vipdata.hbm.xml"/> </session-factory></hibernate-configuration>