Calling stored procedure from Hibernate / MySQL: Parameter index out of range (3 > number of parameters, which is 2) -


i receive following error when calling insert stored procedure in hibernate while working mysql db:

hibernate:      { call insertpayment(?, ?) } sie 28, 2013 10:17:19 pm org.hibernate.engine.jdbc.spi.sqlexceptionhelper logexceptions warn: sql error: 0, sqlstate: s1009 sie 28, 2013 10:17:19 pm org.hibernate.engine.jdbc.spi.sqlexceptionhelper logexceptions error: parameter index out of range (3 > number of parameters, 2). exception in thread "main" org.hibernate.exception.genericjdbcexception: not insert: [model_mapping_xml.tpayment] 

stored procedure definition in mysql db:

create procedure insertpayment(                     in pidanother int,                       in pamount decimal(19,4)                                                     ) begin  ...        end 

tpayment.hbm.xml file contains:

<sql-insert callable="true" check="none">     { call insertpayment(?, ?) } </sql-insert> 

implicit call of stored procedure:

// calling stored procedure add payment tpayment newp = new tpayment(); newp.setanother((tanother) session.load(tanother.class, 1)); newp.setamount(bigdecimal.valueof(20)); session.save(newp); 

why "3 > number of parameters" everywhere there 2 parameters procedure? (i can call deletepayment , modifypayment stored procedures in similar way , work fine...).

tpayment mapping:

<hibernate-mapping>     <class name="model_mapping_xml.tpayment" table="tpayment" catalog="db">         <id name="idpayment" type="java.lang.integer">             <column name="idpayment" />             <generator class="identity" />         </id>         <version name="rowvers" type="timestamp" generated="always">             <column name="rowvers" length="19" not-null="true" />         </version>         <many-to-one name="another" class="model_mapping_xml.tanother" fetch="select">             <column name="idanother" not-null="true" />         </many-to-one>         <property name="amount" type="big_decimal">             <column name="amount" scale="4" not-null="true" />         </property>         <property name="date1" type="timestamp">             <column name="date1" length="19" not-null="false" />         </property>         <sql-insert callable="true" check="none">             { call insertpayment(?, ?) }         </sql-insert>         <sql-update callable="true" check="none">             { call modifypayment(?, ?, ?, ?, ?) }         </sql-update>         <sql-delete callable="true" check="none">             { call deletepayment(?, ?) }         </sql-delete>     </class> </hibernate-mapping> 

tanother mapping:

<hibernate-mapping>     <class name="model_mapping_xml.tanother" table="tanother" catalog="db">         <id name="idanother" type="java.lang.integer">             <column name="idanother" />             <generator class="identity" />         </id>         <property name="datebegin" type="date">             <column name="datebegin" length="10" not-null="true" />         </property>         <property name="dateend" type="date">             <column name="dateend" length="10" />         </property>         <property name="rowvers" type="timestamp">             <column name="rowvers" length="19" not-null="true" />         </property>         <set name="payment" table="tpayment"                  inverse="true" lazy="true" fetch="select">             <key>                 <column name="idanother" not-null="true" />             </key>             <one-to-many class="model_mapping_xml.tpayment" />         </set>     </class> </hibernate-mapping> 


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -