-->
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.  [ 2 posts ] 
Author Message
 Post subject: Exception: Trying to Call Mysql 5.0 Stored Procedure
PostPosted: Thu Sep 28, 2006 8:36 am 
Newbie

Joined: Fri Aug 04, 2006 3:16 am
Posts: 3
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
Hibernate 3.2
Mapping documents:
<sql-query name="selectAllProductGroups" callable="true">
<return alias="dept" class="no.smc.entity.ProductGroup">
<return-property name="pgrId" column="PGR_ID"/>
</return>
{ call changeAllDiffProdGroup(?,?,?,?,?) }

</sql-query>



Code between sessionFactory.openSession() and session.close():

Query q=session.getNamedQuery("no.smc.entity.ProductGroup.selectAllProductGroups");
q.setString(0,dgr);
q.setString(1,pgr);
q.setString(2,text);
q.setFloat(3,updatedDifference);
q.setInteger(4,productMngrId);
q.executeUpdate();

samproductGroupList=q.list();

Full stack trace of any exception that occurs:
org.hibernate.exception.GenericJDBCException: could not execute query

Name and version of the database you are using:
Mysql 5.0

Stored procedure

delimiter //
DROP PROCEDURE IF EXISTS changeAllDiffProdGroup;
//
delimiter //
create procedure changeAllDiffProdGroup(IN filterDgr VARCHAR(3),IN filterPgr VARCHAR(6),IN filterText VARCHAR(255),IN diffpgroup NUMERIC(3,1),IN prodmgrid INTEGER )
begin

DECLARE fDgr VARCHAR(3);
DECLARE fPgr VARCHAR(6);
DECLARE fText VARCHAR(255);

set fDgr=CONCAT(filterDgr,"%");
select fDgr;

set fPgr=CONCAT(filterPgr,"%");
select fPgr;

set fText=CONCAT(filterText,"%");
select fText;

call changeAllFilterDiffProdGroup(fDgr,fPgr,fText,diffpgroup,prodmgrid );
SELECT PGR_ID FROM PRODUCT_GROUP AS PG,DISCOUNT_GROUP AS DG WHERE PG.DGR_ID=DG.DGR_ID AND DG.DGR LIKE filterDgr AND PG.PGR LIKE filterPgr AND PG.TEXT LIKE filterText AND DG.PROD_MNGR_ID=prodmgrid;


end; //
delimiter ;



[The error


If we call the prepared statement , the procedure gets executed and the
database gets updated. There is no exception being thrown. But when we try
to refresh the session cache by doing a HQL query it throws a GenericJDBCException


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 28, 2006 11:40 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Your q is an update statement. You can't use q.list() after q.executeUpdate(). Use a different query.

_________________
Code tags are your friend. Know them and use them.


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

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.