ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hill_...@hsbc.ca
Subject Re: How to get both of return value and return result
Date Wed, 05 Sep 2007 13:54:47 GMT
It is still not working. I simplify the code to avoid the nested result 
map, after that I still can not get the result set back. Here is my latest 
code:

1. Parameter Map:

        <parameterMap id="globalParameter" class="java.util.HashMap" >
                <parameter property="pReturnCode" jdbcType="INTEGER" 
javaType="java.lang.Integer" mode="OUT"/> 
                <parameter property="pUSERID" jdbcType="INTEGER" javaType=
"java.lang.Integer" mode="IN"/>
        </parameterMap>

2. Result Map:

        <typeAlias type="testComplexCollection.Model.FlatUserProfile" 
alias="flatUserProfile"/>
 
        <resultMap class="flatUserProfile" id="flatUserProfileResult">
                <result property="userID" column="UserID"/>
                <result property="userName" column="UserName"/>
                <result property="groupName" column="UserGroupName"/> 
        </resultMap>

3. Procedure Map:
        <procedure id="getFlatUserProfile" parameterMap="globalParameter" 
resultMap="flatUserProfileResult">
                {? = call HILLXIE.TEST_GETUSERSBYID (?)}
        </procedure>

4. DAO Code:

                HashMap parameters = new HashMap();
                Integer returnCode = new Integer(-1);
                parameters.put("pReturnCode", returnCode);
                parameters.put("pUserID", new Integer(userID)); 
 
                FlatUserProfile flatUserProfile = 
(FlatUserProfile)getSqlMapClientTemplate().queryForObject(
"getFlatUserProfile", parameters);

5. Stored procedure:

        DECLARE DB2_SP_SQL1 CURSOR WITH RETURN FOR 
               Select UserID, UserName, UserGroupName FROM USERS WHERE 
UserID = pUserID; 

       OPEN DB2_SP_SQL1; 
       RETURN 100; 

6. Model:

package testComplexCollection.Model;

import java.lang.String;

public class FlatUserProfile {

        private int userID;
        private String userName;
        private String groupName;
        public String getGroupName() {
                return groupName;
        }
        public void setGroupName(String groupName) {
                this.groupName = groupName;
        }
        public int getUserID() {
                return userID;
        }
        public void setUserID(int userID) {
                this.userID = userID;
        }
        public String getUserName() {
                return userName;
        }
        public void setUserName(String userName) {
                this.userName = userName;
        }

}

It looks like a bug for me, any help would be highly appreciated.

------------------------------------------------------
Hill Xie




Hill_XIE@hsbc.ca 
28/08/2007 07:24 PM
Please respond to
user-java@ibatis.apache.org


To
"user-java" <user-java@ibatis.apache.org>
cc

Subject
Re: How to get both of return value and return result






Thank you for reply. I am using nested result map. The result map works 
well if the return value is not checked. For example if the syntax of the 
callable statement is:
        {call TEST_GETUSERSBYID (?)} 
Then the result set can be mapped to the object without problem. I will 
try your scenario (using output parameter instead of return value) to see 
if it works for me. Maybe I should also try not to use the nested result 
map too.

Hill

 ----- Original Message -----
  From: "Jeff Butler" [jeffgbutler@gmail.com]
  Sent: 08/28/2007 02:44 PM
  To: user-java@ibatis.apache.org
  Subject: Re: How to get both of return value and return result

This should be supported.  I just ran a quick test with MySql and 
everything was OK (a SP with OUT parameters and a result set).  This is 
not exactly your scenario, but the idea is the same.
 
You did not share your result map - so it's hard to tell if there might be 
a problem there or not.  There is a known bug if you're using only nested 
result maps, or in certain circumstances where there are nulls in the 
result set. 
 
Jeff Butler

 
On 8/28/07, Hill_XIE@hsbc.ca <Hill_XIE@hsbc.ca> wrote: 

Hi, 

I am very sorry to repost this, because my original thread was occupied. 
Here is my problem: 

I have a DB2 stored procedure returns a single value and a result set at 
the same time, like this: 

        DECLARE DB2_SP_SQL1 CURSOR WITH RETURN FOR 
               Select * FROM USERS WHERE UserID = pUserID; 

       OPEN DB2_SP_SQL1; 
       RETURN 100; 

I tried many times, I can only get the return value (100) back, while the 
return result set is always empty. Here is the iBatis configuration and 
java code: 

1. iBatis Configuration: 

        <parameterMap id= "parameter" class="java.util.HashMap" > 
               <parameter property="pReturnCode" jdbcType="INTEGER" 
javaType ="java.lang.Integer" mode= "OUT"/>         
               <parameter property= "pUSERID" jdbcType="INTEGER" javaType=
"java.lang.Integer" mode ="IN"/> 
        </parameterMap> 

        <procedure id ="getUserProfile" parameterMap= "parameter" 
resultMap="userProfileResult" > 
               {? = call TEST_GETUSERSBYID (?)} 
       </procedure> 

2. Java Code: 

       HashMap parameters = new HashMap(); 
       Integer returnCode = new Integer(-1); 
       parameters.put("ReturnCode", returnCode); 
       parameters.put("UserID", new Integer(userID));                 

       UserProfile userProfile = 
(UserProfile)getSqlMapClientTemplate().queryForObject("getUserProfile", 
parameters); 

3. Result:  userProfile is null, the ReturnCode in the HashMap is 100. 
 
After I debugged into the iBatis code, I found the code does populate some 
data (I am not sure what data it is) into the resultset object. But 
rs.next()returns false, so the code ignores the resultset and doesn't do 
any mapping for the result set. 

Is it unsupported by iBatis? 

Thanks, 
------------------------------------------------------ 
Hill Xie 

***************************************************************
This email may contain confidential information, and is intended only for 
the named recipient and may be privileged. Distribution or copying of this 
email by anyone other than the named recipient is prohibited. If you are 
not the named recipient, please notify us immediately and permanently 
destroy this email and all copies of it. Internet email is not private, 
secure, or reliable. No member of the HSBC Group is liable for any errors 
or omissions in the content or transmission of this email. Any opinions 
contained in this email are solely those of the author and, unless clearly 
indicated otherwise in writing, are not endorsed by any member of the HSBC 
Group. 
***************************************************************
Ce courriel peut renfermer des renseignements confidentiels et privilégiés 
et s'adresse au destinataire désigné seulement. La distribution ou la 
copie de ce courriel par toute personne autre que le destinataire désigné 
est interdite. Si vous n'êtes pas le destinataire désigné, veuillez nous 
en aviser immédiatement et détruire de façon permanente ce courriel ainsi 
que toute copie de celui-ci. La transmission de courriel par Internet ne 
constitue pas un mode de transmission confidentiel, sécuritaire ou fiable. 
Aucun membre du Groupe HSBC ne sera responsable des erreurs ou des 
omissions relatives au contenu ou à la transmission de ce courriel. 
L'auteur de ce courriel est seul responsable des opinions émises dans ce 
courriel, lesquelles, à moins d'un avis contraire fourni par écrit, ne 
sont pas endossées par aucun membre du Groupe HSBC. 
***************************************************************

"SAVE PAPER - THINK BEFORE YOU PRINT!"

"ÉCONOMISEZ LE PAPIER – PENSEZ-Y À DEUX FOIS AVANT D'IMPRIMER!"


***************************************************************
This email may contain confidential information, and is intended only for 
the named recipient and may be privileged. Distribution or copying of this 
email by anyone other than the named recipient is prohibited. If you are 
not the named recipient, please notify us immediately and permanently 
destroy this email and all copies of it. Internet email is not private, 
secure, or reliable. No member of the HSBC Group is liable for any errors 
or omissions in the content or transmission of this email. Any opinions 
contained in this email are solely those of the author and, unless clearly 
indicated otherwise in writing, are not endorsed by any member of the HSBC 
Group.
***************************************************************
Ce courriel peut renfermer des renseignements confidentiels et privil?gi?s 
et s'adresse au destinataire d?sign? seulement. La distribution ou la 
copie de ce courriel par toute personne autre que le destinataire d?sign? 
est interdite. Si vous n'?tes pas le destinataire d?sign?, veuillez nous 
en aviser imm?diatement et d?truire de fa?on permanente ce courriel ainsi 
que toute copie de celui-ci. La transmission de courriel par Internet ne 
constitue pas un mode de transmission confidentiel, s?curitaire ou fiable. 
Aucun membre du Groupe HSBC ne sera responsable des erreurs ou des 
omissions relatives au contenu ou ? la transmission de ce courriel. 
L'auteur de ce courriel est seul responsable des opinions ?mises dans ce 
courriel, lesquelles, ? moins d'un avis contraire fourni par ?crit, ne 
sont pas endoss?es par aucun membre du Groupe HSBC.
***************************************************************

"SAVE PAPER - THINK BEFORE YOU PRINT!"

"?CONOMISEZ LE PAPIER ? PENSEZ-Y ? DEUX FOIS AVANT D'IMPRIMER!"



***************************************************************
This email may contain confidential information, and is intended only for the named recipient
and may be privileged. Distribution or copying of this email by anyone other than the named
recipient is prohibited. If you are not the named recipient, please notify us immediately
and permanently destroy this email and all copies of it. Internet email is not private, secure,
or reliable.  No member of the HSBC Group is liable for any errors or omissions in the content
or transmission of this email. Any opinions contained in this email are solely those of the
author and, unless clearly indicated otherwise in writing, are not endorsed by any member
of the HSBC Group.
***************************************************************
Ce courriel peut renfermer des renseignements confidentiels et privilgis et s'adresse au
destinataire dsign seulement.   La distribution ou la copie de ce courriel par toute personne
autre que le destinataire dsign est interdite.  Si vous n'tes pas le destinataire dsign,
veuillez nous en aviser immdiatement et dtruire de faon permanente ce courriel ainsi que
toute copie de celui-ci. La transmission de courriel par Internet ne constitue pas un mode
de transmission confidentiel, scuritaire ou fiable. Aucun membre du Groupe HSBC ne sera responsable
des erreurs ou des omissions relatives au contenu ou  la transmission de ce courriel.  L'auteur
de ce courriel est seul responsable des opinions mises dans ce courriel, lesquelles,  moins
 d'un avis contraire fourni par crit, ne sont pas endosses par aucun membre du Groupe HSBC.
***************************************************************

"SAVE PAPER - THINK BEFORE YOU PRINT!"

"CONOMISEZ LE PAPIER  PENSEZ-Y  DEUX FOIS AVANT D'IMPRIMER!"

Mime
View raw message