ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Fábio Pisaruk" <pisa...@gmail.com>
Subject Re: Get return value and return result set
Date Mon, 27 Aug 2007 21:45:03 GMT
First of all i´s like to thank for the immediate response.
Second, i wanna apologize for posting a new question in an already oppened
thread. My bad.
Third, As far as i´m concerned you have just pointed out the missing
namespace at my code.
I´ve added it but it didn´t work. I am still having the same error.
Here is my real code:

<sqlMap namespace="nsGuiaConsulta">
<resultMap class="xml" id="get-guias" xmlName="guiaConsulta">
        <result property="beneficiario" resultMap="get-beneficiario"
javaType="ctBeneficiario"/>
        <result property="cid" javaType="xmlCollection" column="num_lote"
select="nsGuiaConsulta.getCID"/>
    </resultMap>

    <resultMap class="xml" id="get-beneficiario" xmlName="beneficiario">
        <result property="numeroCarteira"
column="numeroCarteiraBeneficiario"/>
        <result property="nomeBeneficiario" column="nomeBeneficiario"/>
        <result property="nomePlano" column="nomePlano"/>
        <result property="validadeCarteira"
column="validadeCarteiraBeneficiario"/>
        <result property="numeroCNS" column="numeroCNSBeneficiario"/>
    </resultMap>

    <resultMap class="xml" id="get-header" xmlName="identificacaoGuia">
        <result property="dataEmissaoGuia" column="dataEmissaoGuia"/>
        <result property="numeroGuiaPrestador"
column="numeroGuiaPrestador"/>
        <result property="numeroGuiaOperadora"
column="numeroGuiaOperadora"/>
        <result property="registroANS" column="registroANS"/>
    </resultMap>

    <resultMap class="xml" id="get-cids">
        <result property="cid" column="seq_conta"/>
    </resultMap>

    <select id="getLoteGuias" parameterClass="int" resultMap="get-guias">
        <include refid="campos-guia-tiss"/>
        where             c.seq_lote = #seq_lote#
    </select>


    <select id="nsGuiaConsulta.getCID" resultMap="get-cids"
parameterClass="int">
        select seq_conta
        from   tiss_conta
        where  seq_lote = 943344
    </select>
</sqlMap>

Forget about campos-guia-tiss. Consider that it return all required fields.

The error i´m receiving is:

org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation;
uncategorized SQLException for SQL []; SQL state [null]; error code [0];
--- The error occurred in
br/com/crc/tiss/arquivo/data/ibatis/sqlMaps/GuiaDeConsulta.xml.
--- The error occurred while applying a result map.
--- Check the nsGuiaConsulta.get-guias.
--- Check the result mapping for the 'cid' property.
--- Cause: com.ibatis.sqlmap.client.SqlMapException: There is no statement
named nsGuiaConsulta.getCID in this SqlMap.; nested exception is
com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in
br/com/crc/tiss/arquivo/data/ibatis/sqlMaps/GuiaDeConsulta.xml.
--- The error occurred while applying a result map.
--- Check the nsGuiaConsulta.get-guias.
--- Check the result mapping for the 'cid' property.
--- Cause: com.ibatis.sqlmap.client.SqlMapException: There is no statement
named nsGuiaConsulta.getCID in this SqlMap.
Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in
br/com/crc/tiss/arquivo/data/ibatis/sqlMaps/GuiaDeConsulta.xml.
--- The error occurred while applying a result map.
--- Check the nsGuiaConsulta.get-guias.
--- Check the result mapping for the 'cid' property.
--- Cause: com.ibatis.sqlmap.client.SqlMapException: There is no statement
named nsGuiaConsulta.getCID in this SqlMap.
    at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback
(GeneralStatement.java:188)
    at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForList
(GeneralStatement.java:123)
    at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(
SqlMapExecutorDelegate.java:615)
    at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(
SqlMapExecutorDelegate.java:589)
    at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(
SqlMapSessionImpl.java:118)
    at
org.springframework.orm.ibatis.SqlMapClientTemplate$3.doInSqlMapClient(
SqlMapClientTemplate.java:268)
    at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(
SqlMapClientTemplate.java:193)
    at
org.springframework.orm.ibatis.SqlMapClientTemplate.executeWithListResult(
SqlMapClientTemplate.java:219)
    at org.springframework.orm.ibatis.SqlMapClientTemplate.queryForList(
SqlMapClientTemplate.java:266)
    at br.com.crc.tiss.arquivo.data.GuiaConsultaDAO.getLoteGuias(
GuiaConsultaDAO.java:145)
    at test.suites.dao.GuiaDeConsultaDAOTest.testGetLoteGuias(
GuiaDeConsultaDAOTest.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at junit.framework.TestCase.runTest(TestCase.java:164)
    at junit.framework.TestCase.runBare(TestCase.java:130)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:120)
    at junit.framework.TestSuite.runTest(TestSuite.java:230)
    at junit.framework.TestSuite.run(TestSuite.java:225)
    at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(
JUnit3TestReference.java:130)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(
TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
RemoteTestRunner.java:460)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
RemoteTestRunner.java:673)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(
RemoteTestRunner.java:386)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
RemoteTestRunner.java:196)
Caused by: com.ibatis.sqlmap.client.SqlMapException: There is no statement
named nsGuiaConsulta.getCID in this SqlMap.
    at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.getMappedStatement(
SqlMapExecutorDelegate.java:293)
    at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.getMappedStatement(
SqlMapClientImpl.java:202)
    at
com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.getNestedSelectMappingValue
(BasicResultMap.java:471)
    at com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.getResults(
BasicResultMap.java:336)
    at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(
SqlExecutor.java:381)
    at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleMultipleResults(
SqlExecutor.java:301)
    at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(
SqlExecutor.java:190)
    at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteQuery(
GeneralStatement.java:205)
    at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback
(GeneralStatement.java:173)
    ... 28 more

I have no idea what is wrong. I´ve read a post saying that using
xmlCollection java type should solve this problem.

Thanks Anyway



On 8/27/07, Hill_XIE@hsbc.ca <Hill_XIE@hsbc.ca> wrote:
>
>
> Referring to the section "Avoiding N+1 Selects" of the document "iBATIS
> Data Mapper 2.0", you need to specify the namespace like this:
>
> <sqlMap namespace="PersonContactInfo">        <--- Specify the namespace
> here
>
> <resultMap id="person-ResultMap" class="xml" groupBy="personID">
>  ...
>   ...
>  <result property="phones" resultMap="PersonContactInfo.phone-ResultMap"/>
>      <--- Specify the namespace here
> <resultMap/>
>
> <resultMap id="phone-ResultMap" class="xml">
>  ...
>   ...
> <resultMap/>
>
> </sqlMap>
>
> ------------------------------------------------------
> Hill Xie
>
>
>
>  *"Fábio Pisaruk" <pisaruk@gmail.com>*
>
> 27/08/2007 04:16 PM
>  Please respond to
> user-java@ibatis.apache.org
>
>   To
> user-java@ibatis.apache.org  cc
>
>  Subject
> Re: Get return value and return result set
>
>
>
>
>
>
> Hi guys!
>
> I´m trying to use ibatis to generate xml from my tables but i can´t find
> any useful examples to do so.
> I have the following problem: Suppose there are two tables named Person,
> Phones. I´d like to generate a xml document like this:
>
> <Person>
>  <PersonID>9999<PersonID>
>  <Name>Name of person</Name>
>  <Phones>
>    <Phone>5555-5555</Phone>
>    <Phone>1111-5555</Phone>
>    <Phone>2222-5555</Phone>
>  <Phones>
> </Person>
>
> Here are my maps:
>
> <resultMap id="person-ResultMap" class="xml" groupBy="personID">
>  <result property="name" column="name"/>
>  <result property="personID" column="personID"/>
>  <result property="phones" resultMap="phone-ResultMap"/>
> <resultMap/>
>
> <resultMap id="phone-ResultMap" class="xml">
>  <result property="name" column="name"/>
>  <result property="personID" column="personID"/>
> <resultMap/>
>
> <select id="getPerson" parameterClass="int" resultMap="person-ResultMap">
>        select name,number,personID
>        from Person,Phone
>        where personID= ?
> </select>
>
> But i can´t make it to work.
> I think that ibatis doesn´t support nested lists :-(
>
> Thanks in advance.
>
>
>
>
>
>
>
> On 8/27/07, *Hill_XIE@hsbc.ca* <Hill_XIE@hsbc.ca> <*Hill_XIE@hsbc.ca*<Hill_XIE@hsbc.ca>>
> wrote:
>
> Hi Brandon,
>
> Thank you for your reply. I did try it with the straight JDBC, and it
> works. In straight JDBC the return value of the stored procedure is the
> first output parameter of the callable statement.
> ------------------------------------------------------
> Hill Xie
>
>
>   *"Brandon Goodin" <**brandon.goodin@gmail.com*<brandon.goodin@gmail.com>
> *>*
>
> 27/08/2007 03:45 PM
>   Please respond to*
> **user-java@ibatis.apache.org* <user-java@ibatis.apache.org>
>
>
>   To
> *user-java@ibatis.apache.org* <user-java@ibatis.apache.org>  cc
>
>  Subject
> Re: Get return value and return result set
>
>
>
>
>
>
>
>
> iBATIS uses standard JDBC support for multiple result sets. Have you tried
> implementing this in straight JDBC using your driver to see if it is
> supported by the driver?
>
> Thanks,
> Brandon
>
> On 8/27/07, *Hill_XIE@hsbc.ca* <Hill_XIE@hsbc.ca> <*Hill_XIE@hsbc.ca*<Hill_XIE@hsbc.ca>>
> wrote:
>
> Hi,
>
> 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 sure what data) 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Ã(c)giÃ(c)s et s'adresse au destinataire dÃ(c)signÃ(c) seulement. La
> distribution ou la copie de ce courriel par toute personne autre que le
> destinataire dÃ(c)signÃ(c) est interdite. Si vous n'êtes pas le destinataire
> dÃ(c)signÃ(c), veuillez nous en aviser immÃ(c)diatement et dÃ(c)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Ã(c)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 Ã(c)mises
> dans ce courriel, lesquelles, Ã  moins d'un avis contraire fourni par
> Ã(c)crit, ne sont pas endossÃ(c)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!"
>
>
>
> --
> Visto como se não executa logo a sentença sobre a má obra, o coração dos
> filhos dos homens está inteiramente disposto a praticar o mal.
>
>
> --Nerd´s sign
>
> If you have four classes, Everybody, Somebody, Anybody, and Nobody, if
> Somebody has a bug, it could be Anybody 's fault but Nobody really knows,
> while Everybody shares responsibility.
>
> ***************************************************************
> 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!"
>



-- 
Visto como se não executa logo a sentença sobre a má obra, o coração dos
filhos dos homens está inteiramente disposto a praticar o mal.


--Nerd´s sign

If you have four classes, Everybody, Somebody, Anybody, and Nobody, if
Somebody has a bug, it could be Anybody 's fault but Nobody really knows,
while Everybody shares responsibility.
Mime
View raw message