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.  [ 1 post ] 
Author Message
 Post subject: Hibernate call stored procedure
PostPosted: Thu Jun 23, 2011 11:24 pm 

Joined: Thu Jun 23, 2011 10:48 pm
Posts: 1
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:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"


   <class name="Station" table="stations">

      <composite-id name="id"
         <key-property name="id" />
         <key-property name="cityId" />

      <property name="name">
         <column name="name" length="256" not-null="true" />
           <property name="latitude">
         <column name="latitude" not-null="true" />

      <property name="longitude">
         <column name="longitude" not-null="true" />


   <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 name="name" column="name" />
         <return-property name="latitude" column="latitude" />
         <return-property name="longitude" column="longitude" />
      { ? = call


my java 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:
CREATE DEFINER=`root`@`localhost` PROCEDURE `getStationsByRectangleBounds`(
    lowerBoundX float,
    lowerBoundY float,
    upperBoundX float,
    upperBoundY float
SET @rectangle = CONCAT('POLYGON((',
lowerBoundX, ' ', lowerBoundY, ',',
upperBoundX, ' ', lowerBoundY, ',',
upperBoundX, ' ', upperBoundY, ',',
lowerBoundX, ' ', upperBoundY, ',',
lowerBoundX, ' ', lowerBoundY, '))'
        , cityId
        , name
        , latitude
        , longitude
FROM stations
WHERE Intersects(location, GeomFromText(@rectangle) );


I just started to use Hibernate as my ORM and trying to call the SP to no avail. Really lost. Any help is appreciated.


Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.