-->
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.  [ 5 posts ] 
Author Message
 Post subject: How to call stored procedure
PostPosted: Tue Mar 21, 2006 3:52 am 
Newbie

Joined: Thu Feb 23, 2006 5:54 am
Posts: 12
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.0

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

Hi,

I need to call stored procedure, i am using sql server with hibernate3.0.
Please give answer as soon as possible.

Thanks,
Mohana Priya Korrapati


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 21, 2006 5:46 am 
Regular
Regular

Joined: Tue Jan 03, 2006 9:52 am
Posts: 52
Location: Zurich
See the link below:
http://www.hibernate.org/hib_docs/v3/re ... /#sp_query

Urs


Top
 Profile  
 
 Post subject: Stored Procedure in SQLServer2000
PostPosted: Tue Mar 21, 2006 8:59 am 
Newbie

Joined: Thu Feb 23, 2006 5:54 am
Posts: 12
hi hibernate Experts,

I am new in 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_SP" callable="true">
<return alias="metrics" class="com.utc.pw.acs.hibernate.model.Usermetrics">
<return-property name="firstlogin" column="FIRSTLOGIN"/>
<return-property name="lastactive" column="LASTACTIVE"/>
</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 * 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();
SQLQuery query = (SQLQuery)hbSession.getNamedQuery("sp_test1_SP");List results = query.list();



-----------------------------------------------

Exception:

06/03/21 18:00:58 Closing hibernate Session of this thread.
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.ja
va:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:119
6)
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(Reques
tProcessor.java:386)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja
va:229)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:119
6)
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(HttpReques
tHandler.java:790)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.ja
va:270)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.ja
va: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(Unkn
own Source)
at com.microsoft.jdbc.base.BasePreparedStatement.validateParameters(Unkn
own Source)
at com.microsoft.jdbc.base.BasePreparedStatement.preImplExecute(Unknown
Source)
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:1
49)
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)
... 38 more


Top
 Profile  
 
 Post subject: Re: Stored Procedure in SQLServer2000
PostPosted: Tue Mar 21, 2006 9:25 am 
Regular
Regular

Joined: Wed Feb 22, 2006 11:28 am
Posts: 65
Location: Santiago, Chile
Hello Friend:

To answer your question:

I guess we use Store Procedure when our future business plan will not want to modify the software application (possible at the datas presentation), we use Store Procedure.

In my enterprise, i found this problem. I used many HQL to query to Data Base with the mind "that´s all fantastic, i can optimize all", but when i entered that the application is for 24 persons, let say, one application for 242 person, when someone change his requeriments, we will not holp changing the application, and we wanna not to down the application. Is in that escenary, we use Store Procedure rather than Hibernate Query Lenguage.

Request for comments.

Regards. Neketsu shonen


Top
 Profile  
 
 Post subject: Re: Stored Procedure in SQLServer2000
PostPosted: Wed Mar 29, 2006 6:12 am 
Newbie

Joined: Thu Feb 23, 2006 5:54 am
Posts: 12
neketsushonen wrote:
Hello Friend:

To answer your question:

I guess we use Store Procedure when our future business plan will not want to modify the software application (possible at the datas presentation), we use Store Procedure.

In my enterprise, i found this problem. I used many HQL to query to Data Base with the mind "that´s all fantastic, i can optimize all", but when i entered that the application is for 24 persons, let say, one application for 242 person, when someone change his requeriments, we will not holp changing the application, and we wanna not to down the application. Is in that escenary, we use Store Procedure rather than Hibernate Query Lenguage.

Request for comments.

Regards. Neketsu shonen


hello,

What's my problem is i want to retrieve data from existing application database, that's why i used stored procedure.Pls check the source code
give solution to my problem if possible.

thanks in advance
priya


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.