-->
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: Stored procedure with Spring's HibernateTemplate
PostPosted: Tue Dec 06, 2011 1:09 pm 
Newbie

Joined: Sat Mar 19, 2011 6:12 am
Posts: 2
here's a lot of examples over the net which describe how to call a stored procedure using Hibernate, however, when using Spring, the picture changes a bit.

I have a stored procedure in MySQL which I want to call: in SQL I need to write the following:
Code:
CALL inrange(32.342324,32.234234);
It returns a row with the following: {INT},{INT},{FLOAT}

With Spring, I use the HibernateTemplate way of executing hibernate operations, I know that some of you won't like it, but this is the how the project was when I started, and I'm not so eager changing it, maybe in the future...

Currently, I have the following code in Java, which tries to call the procedure:
Code:
List<Object[]> resultset = hibernateTemplate.findByNamedQuery(
        "inrange", person.getAddress().getLatitude(), person.getAddress().getLongitude());


When I run it, I get the following Hibernate exception:
Quote:
org.springframework.orm.hibernate3.HibernateSystemException: Named query not known: inrange;


I figured that this is happening duo the fact that I didn't declare the stored procedure in hibernate. My question is: how do I declare it ? Is there a special way of declaring it in the Spring's application context file ?


Top
 Profile  
 
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.