aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate; error executing stored procedure Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate; error executing stored procedure" Watch "Hibernate; error executing stored procedure" New topic
Author

Hibernate; error executing stored procedure

M Burke
Ranch Hand

Joined: Jun 25, 2004
Posts: 388
I an getting a perplexing error.

"org.hibernate.exception.GenericJDBCException: could not execute query
com.microsoft.sqlserver.jdbc.SQLServerException: The value is not set for the parameter number 3."

My stored procedure has two parameters, not three.

The signature of the stored proc is...
PROCEDURE [dbo].[SP_GEO_US_FIND_POSTAL_CODES]
@postalCode nvarchar(50),
@radius nvarchar(50)

--returns a list from a select

My hbm looks like this...

<?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="geoUsFindPostalCodesSP" callable="true">

<return class="persistance.ds.jdo.GeoCodes">
<return-property name="code" column="CODE"/>
</return>

{? = call SP_GEO_US_FIND_POSTAL_CODES(?, ?) }
</sql-query>
</hibernate-mapping>



My Java Call...

List<String> params = new LinkedList<String>();
params.add("60990");
params.add("5");

Query query = session.getNamedQuery(geoUsFindPostalCodesSP");
int i = 0;
Iterator<?> ix = params.iterator();
while (ix != null && ix.hasNext())
{
query.setParameter(i, ix.next());
i++;
}

List<GeoCodes> geoCodesList = (List<GeoCodes>) query.list();//error

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate; error executing stored procedure