Hi
I have a (mysql) stored proc called simpleproc
Code:
select count(*) into param1 from entity;
my NamedQueries.hbm.xml is set up as follows:
Code:
<hibernate-mapping>
<sql-query name="sp_simpleproc" callable="true">
<return alias="param1" class="org.matt.test.db.Entity"/>
{call simpleproc(@param1)}
</sql-query>
</hibernate-mapping>
and at the moment I try
Code:
int result = session.getNamedQuery("sp_simpleproc").list().size();
I tried hacking the above named query together because there doesn't appear to be any examples on how a scalar-returning stored proc is used, so I guess this is were the problem is.
Anyway when I run I get this:
ArrayIndexOutOfBoundsException: -1
at com.mysql.jdbc.CallableStatement.setOutParams(CallableStatement.java:1914)
...
at org.hibernate.dialect.MySQLDialect.getResultSet(MySQLDialect.java:316)
...
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:164)
What's the correct hibernate mapping for a (stored proc) named query like the one above? (I know how the normal recordset ones work).