I'm trying to call a stored procedure from mysql db.
I'm getting the SEVERE: Can't set IN parameter for return value of stored function call.
Exception in thread "main" org.hibernate.exception.GenericJDBCException: could not execute query
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140)
in my configuration i have the follow:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="Station" table="stations">
<composite-id name="id"
class="StationId">
<key-property name="id" />
<key-property name="cityId" />
</composite-id>
<property name="name">
<column name="name" length="256" not-null="true" />
</property>
<property name="latitude">
<column name="latitude" not-null="true" />
</property>
<property name="longitude">
<column name="longitude" not-null="true" />
</property>
</class>
<sql-query name="getStationsByRectangleBounds" callable="true">
<return alias="station" class="Station">
<return-property name="id">
<return-column name="id" />
<return-column name="cityId" />
</return-property>
<return-property name="name" column="name" />
<return-property name="latitude" column="latitude" />
<return-property name="longitude" column="longitude" />
</return>
{ ? = call
getStationsByRectangleBounds(:lowerBoundX,:lowerBoundY,:upperBoundX,:upperBoundY)
}
</sql-query>
</hibernate-mapping>
my java code
Code:
Query query = session.getNamedQuery("getStationsByRectangleBounds");
query.setParameter("lowerBoundX", new Float(45.531155));
query.setParameter("lowerBoundY", new Float(-73.598183));
query.setParameter("upperBoundX", new Float(45.538300));
query.setParameter("upperBoundY", new Float(-73.582703));
List<Station> list = query.list();
the SP:
Code:
CREATE DEFINER=`root`@`localhost` PROCEDURE `getStationsByRectangleBounds`(
lowerBoundX float,
lowerBoundY float,
upperBoundX float,
upperBoundY float
)
BEGIN
SET @rectangle = CONCAT('POLYGON((',
lowerBoundX, ' ', lowerBoundY, ',',
upperBoundX, ' ', lowerBoundY, ',',
upperBoundX, ' ', upperBoundY, ',',
lowerBoundX, ' ', upperBoundY, ',',
lowerBoundX, ' ', lowerBoundY, '))'
);
SELECT id
, cityId
, name
, latitude
, longitude
FROM stations
WHERE Intersects(location, GeomFromText(@rectangle) );
END
I just started to use Hibernate as my ORM and trying to call the SP to no avail. Really lost. Any help is appreciated.
Thanks,