-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: Using Stored Procedure wich return more than one Result Set
PostPosted: Wed Dec 07, 2005 10:38 am 
Newbie

Joined: Fri Dec 02, 2005 11:33 am
Posts: 10
Location: Québec, Canada
I'm using Hibernate 3.1 with DB2.

I’m trying, without any success, to use a stored procedure (SP), which returns two result sets.

With Hibernate, I’m able to use a SP which returns one result set without any problem.

With JDBC, I’m able to use a SP which returns more than one result set and access all the result sets. But I’m not able to map the two result sets to two Java classes using Hibernate.

Anyone is using SP which returns more than one result set with Hibernate?

François J.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 07, 2005 12:43 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
not supported.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 07, 2005 5:53 pm 
Newbie

Joined: Fri Dec 02, 2005 11:33 am
Posts: 10
Location: Québec, Canada
Is there any plan in supporting this feature in the future?

If I’m interested in adding support for this feature where can I start?

Thank You.

François J.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 07, 2005 6:03 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
start by figuring out how you would actually map it ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 07, 2005 8:39 pm 
Newbie

Joined: Fri Dec 02, 2005 11:33 am
Posts: 10
Location: Québec, Canada
It’s a naive initiative, but let’s image a store procedure, SELECT_PERSON_ADDRESS, which need two input arguments and returns two result sets. I would imagine something like this to do the mapping.

<sql-query name="SELECT2_WT_HOSPITAL_SP" callable="true">
<!-- First result set -->
<return alias="per" class="com.something.persistence.Person">
<return-property name="id" column="ID" />
<return-property name="name" column="NAME" />
<return-property name="father" column="Father" />
</return>
<!-- Second result set -->
<return alias="add" class="com.something.persistence.Address">
<return-property name="id" column="ID" />
<return-property name="address" column="ADDRESS" />
<return-property name="zip" column="ZIP" />
<return-property name="phone" column="PHONE" />
</return>
{ call SELECT_PERSON_ADDRESS(?, ?) }
</sql-query>

I understand that it’s not now implemented but if it may be done, I would like to help and have some hints on where to start.

François J.


Top
 Profile  
 
 Post subject: I got problem while calling stored procedure
PostPosted: Mon Mar 27, 2006 6:24 am 
Newbie

Joined: Thu Feb 23, 2006 5:54 am
Posts: 12
fjean wrote:
It’s a naive initiative, but let’s image a store procedure, SELECT_PERSON_ADDRESS, which need two input arguments and returns two result sets. I would imagine something like this to do the mapping.

<sql-query name="SELECT2_WT_HOSPITAL_SP" callable="true">
<!-- First result set -->
<return alias="per" class="com.something.persistence.Person">
<return-property name="id" column="ID" />
<return-property name="name" column="NAME" />
<return-property name="father" column="Father" />
</return>
<!-- Second result set -->
<return alias="add" class="com.something.persistence.Address">
<return-property name="id" column="ID" />
<return-property name="address" column="ADDRESS" />
<return-property name="zip" column="ZIP" />
<return-property name="phone" column="PHONE" />
</return>
{ call SELECT_PERSON_ADDRESS(?, ?) }
</sql-query>

I understand that it’s not now implemented but if it may be done, I would like to help and have some hints on where to start.

François J.



I got problem while calling stored procedure.Please give solution.

I am using hibernate3 version for executing stored procdure in SQLserver 2000.

I have started working on this by learining from www.hibernate.org.

I am getting below error and could not rectify from few days.
Could any one add your comments for Stored procedure execution for SQL
server 2000.
Where can i get information regarding execution of Stored procedures for
SQL server in hibernat3

-------------------------------------------------
XML Mapping for Calling Stored Procedure

<sql-query name="sp_test1" callable="true">
<return alias="per" class="com.utc..hibernate.model.Usermetrics">
<return-property name="portalsession" column="PORTALSESSION" />
</return>
{? = call sp_test1() }
</sql-query>

----------------------------------------------
SQL Server Stored Procedure

SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
ALTER PROC sp_test1 @sowcursor cursor varying OUT AS

DECLARE s CURSOR
LOCAL
FOR SELECT PORTALSESSION FROM acs.dbo.Usermetrics
OPEN s
SET @sowcursor=s
RETURN(0)

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
-------------------------------------------------

Calling procedure in DAO

hbSession = (Session)CSessionFactory.getSession();
Query query = (hbSession.getNamedQuery("sp_test1");
List results = query.list();
-----------------------------------------------

Exception:
org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.j
ava:65)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelp
er.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:2153)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:117)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1607)

at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:
121)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:169)
at com.utc.pw.acs.hibernate.dao.CMainMenuDAO.getMetrics(CMainMenuDAO.jav
a:76)
at com.utc.pw.acs.action.CMainMenuAction.loadMainMenu(CMainMenuAction.ja va:203)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchActio n.java:274)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java: 194)
at org.apache.struts.action.RequestProcessor.processActionPerform(Reques tProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletReque
stDispatcher.java:765)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(Ser
vletRequestDispatcher.java:317)
at com.evermind.server.http.ServletRequestDispatcher.forward(ServletRequ
estDispatcher.java:220)
at com.evermind.server.http.GetParametersRequestDispatcher.forward(GetPa
rametersRequestDispatcher.java:257)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor. java:1062)
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:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletReque
stDispatcher.java:765)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(Ser
vletRequestDispatcher.java:317)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.ja va:270)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(Relea
sableResourcePooledExecutor.java:186)
at java.lang.Thread.run(Thread.java:534)
Caused by: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for
JDBC]Inv
alid parameter binding(s).
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source )
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.base.BasePreparedStatement.validateParameters(Unknown Source)
at com.microsoft.jdbc.base.BasePreparedStatement.validateParameters(Unknown Source)
at com.microsoft.jdbc.base.BasePreparedStatement.preImplExecute(UnknownSource)
at com.microsoft.jdbc.base.BaseStatement.commonExecute(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.executeInternal(Unknown Source)
at com.microsoft.jdbc.base.BasePreparedStatement.execute(Unknown Source)
at org.hibernate.dialect.SybaseDialect.getResultSet(SybaseDialect.java:149)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:146)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1666)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Lo ader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2150)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.