-->
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: MySQL stored procedure returns only one row with JPA
PostPosted: Fri Nov 02, 2012 7:28 am 
Newbie

Joined: Fri Jun 15, 2007 2:32 pm
Posts: 16
Hello,

I am calling a stored procedure that should return multiple rows but only one row is returned. Each row is converted to an entity:

Code:
EntityManager.Query.createNativeQuery("{ CALL my_procedure() }", MyEntity.class).getResultList()


After debugging, I can see that the "rs.next()" in org.hibernate.loader.Loader.doQuery return true in the first iteration and false in the next iteration.

As far as I know, for stored procedures (at least with MySQL) the "has more rows" check should be done on the statement:

Code:
statement.execute(); // If true, there is at least one row and keep iterating while (statement.getMoreResults())


I confirmed that using the debugger and evaluating "rs.getStatement().getMoreResults()" which returns true while "rs.next()" is false.

I know JPA does not officially support stored procedures but how can I workaround this issue?

hibernate 4.1.3
hibernate-jpa-2.0-api-1.0.1.Final


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.