论坛首页 入门技术论坛

hibernate查询时出现的问题

浏览 3473 次
该帖已经被评为新手帖
作者 正文
   发表时间:2008-06-13  
org.hibernate.InstantiationException: No default constructor for entity: com.tks.skyproject.model.ImplementLogAttach
at org.hibernate.tuple.PojoInstantiator.instantiate(PojoInstantiator.java:90)
at org.hibernate.tuple.PojoInstantiator.instantiate(PojoInstantiator.java:106)
at org.hibernate.tuple.AbstractEntityTuplizer.instantiate(AbstractEntityTuplizer.java:344)
at org.hibernate.persister.entity.AbstractEntityPersister.instantiate(AbstractEntityPersister.java:3272)
at org.hibernate.impl.SessionImpl.instantiate(SessionImpl.java:1239)
at org.hibernate.impl.SessionImpl.instantiate(SessionImpl.java:1228)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1291)
at org.hibernate.loader.Loader.getRow(Loader.java:1197)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:569)
at org.hibernate.loader.Loader.doQuery(Loader.java:689)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at com.tks.skyproject.implementLog.dao.hibernate.ImplementLogDaoImpl.findImplementLogAttachs(ImplementLogDaoImpl.java:662)
at com.tks.skyproject.implementLog.service.impl.ImplementLogFactoryImpl.findImplementLogAttachs(ImplementLogFactoryImpl.java:232)
at org.apache.jsp.implementLog.list_005fimplementLogs_jsp._jspService(org.apache.jsp.implementLog.list_005fimplementLogs_jsp:616)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1063)
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:386)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:229)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:667)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)


我的实体类和数据库中映射了,字段与实体类中的属性也映射了,字段的类型也与实体类中的类型映射了,可是就是查不出来,费了一个多小时,最后发现是在实体类中没有空的构造函数,加上就好了。改变一下思维:用这样查是不出错的:select il.subject from ImplmentLog 因为它查的是实体类对应的字段。
   发表时间:2008-06-13  
引用
No default constructor for entity

就这样你还费了一个多小时才发现错误!
0 请登录后投票
   发表时间:2008-06-13  
No default constructor for entity
0 请登录后投票
   发表时间:2008-06-13  
检查一下构造函数吧哥们
0 请登录后投票
   发表时间:2008-06-16  
那平时这样的错误,你是怎么处理的?
0 请登录后投票
   发表时间:2008-08-16  
No default constructor for entity
这不是很明显吗,实体类没有默认的构造函数。虽说咱英语水平不怎么样,但这个还是能看出来的。
0 请登录后投票
   发表时间:2008-09-05  
[color=olive][i][/i][u][/u]
引用

    [*]

    [*]
[img][/img][url][/url][flash=200,200][/flash][/color]
0 请登录后投票
论坛首页 入门技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics