-->
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.  [ 3 posts ] 
Author Message
 Post subject: Need Help With Stored Proedure call
PostPosted: Fri Apr 28, 2006 2:15 pm 
Newbie

Joined: Fri Apr 28, 2006 1:57 pm
Posts: 2
Please let me know what changes are needed



Hibernate version:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>

<sql-query name="selectAllRegions_p" callable="true">
<return alias="st" class="src.main.java.State">
<return-property name="stateid" column="REGIONID" />
<return-property name="stateabbr" column="REGIONCODE" />
<return-property name="statename" column="NAME" />
<return-property name="countryID" column="COUNTRYID" />
</return>
{ ? = call getAllRegions() }
</sql-query>

</hibernate-mapping>

Mapping documents:

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

Query query = session.getNamedQuery("selectAllRegions_p");
List result = query.list();

Full stack trace of any exception that occurs:

Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:2148)
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:111)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1655)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:164)
at src.main.java.TestHibernateApp.listEvents(TestHibernateApp.java:36)
at src.main.java.TestHibernateApp.main(TestHibernateApp.java:13)
Caused by: java.sql.SQLException: Parameter #1 has not been set.
at net.sourceforge.jtds.jdbc.TdsCore.executeSQL(TdsCore.java:1005)
at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQL(JtdsStatement.java:478)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.execute(JtdsPreparedStatement.java:478)
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(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
... 8 more
Hibernate: { ? = call getAllRegions() }

Name and version of the database you are using:

sql server2005

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject: I guess
PostPosted: Fri Apr 28, 2006 2:27 pm 
Regular
Regular

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

If you see in detail ur exception trace, you will found the follow line:

Caused by: java.sql.SQLException: Parameter #1 has not been set.

Cos your Store Procedure is write:
? = call getAllRegions() , where the character "?" means implicitly a parameter, so u have tu set a parameter there to excecute.

I think u use Oracle DB, u can search in the hibernate forum all topics associed to Store Procedure of your data base.


Requests for comments


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 28, 2006 2:45 pm 
Newbie

Joined: Fri Apr 28, 2006 1:57 pm
Posts: 2
Thank you,

I removed the " ? =" from my code and i was able to retrieve the data.

Question
"? = call getAllRegions() " is this to register the return type of the procedure call to a variable ?

do we have to do some setXX method to get it into a variable.


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