Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.0
Mapping documents:
<hibernate-mapping>
<class name="com.didit.targit.db.domain.CategoriesProducts" table="categories_products">
<id name="categoryProductId" column="id">
<generator class="increment" />
</id>
<property name="categoryProductName" column="name" not-null="true" />
<property name="categoryProductDescription" column="description" not-null="true" />
<property name="categoryProductIscategory" column="is_category" not-null="true" />
<property name="categoryProductParentId" column="parent_id" not-null="true" />
</class>
<sql-query name="getTree" callable="true">
<return alias="tree" class="com.didit.targit.db.domain.CategoriesProducts">
<return-property name="categoryProductId" column="id" />
<return-property name="categoryProductName" column="name" />
<return-property name="categoryProductDescription" column="description" />
<return-property name="categoryProductIscategory" column="is_category" />
<return-property name="categoryProductParentId" column="parent_id" />
<!--
<return-property name="intDeptId" column="dept_id"/>
<return-property name="strDeptName" column="dept_name"/>
-->
</return>
{ ? = call getTree() }
</sql-query>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
session = HibernateHelper.getSession();
for (Iterator it = session.createQuery("from gettree()").list().iterator();it.hasNext();) {
categoriesproducts = new CategoriesProducts();
CategoriesProducts tmpcategoriesproducts = (CategoriesProducts)it.next();
categoriesproducts.setcategoryProductDescription(tmpcategoriesproducts.getcategoryProductDescription());
categoriesproducts.setcategoryProductId(tmpcategoriesproducts.getcategoryProductId());
categoriesproducts.setcategoryProductIscategory(tmpcategoriesproducts.getcategoryProductIscategory());
categoriesproducts.setcategoryProductName(tmpcategoriesproducts.getcategoryProductName());
categoriesproducts.setcategoryProductParentId(tmpcategoriesproducts.getcategoryProductParentId());
productsbytree.add(categoriesproducts);
}
} catch (HibernateException _e) {
_e.printStackTrace();
} finally {
if (session != null) {
session.flush();
session.close();
}}
Full stack trace of any exception that occurs:
java.lang.UnsupportedOperationException: org.hibernate.dialect.PostgreSQLDialect does not support resultsets via stored procedures.
at org.hibernate.dialect.Dialect.registerResultSetOutParameter(Dialect.java:791)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1175)
at org.hibernate.loader.Loader.doQuery(Loader.java:390)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.doList(Loader.java:1593)
at org.hibernate.loader.Loader.list(Loader.java:1577)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:112)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1414)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:153)
at com.didit.targit.db.daoimpl.CategoriesProductsDaoImpl.getTree(CategoriesProductsDaoImpl.java:260)
at org.apache.jsp.WEB_002dINF.jsp.view.viewConversionScales_jsp._jspService(viewConversionScales_jsp.java:123)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:704)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:474)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:409)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1063)
at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:263)
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:386)
at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:318)
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:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Unknown Source)
Name and version of the database you are using:
Postgres SQL 8.1
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: