ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <guillen.olmos.an...@servexternos.repsolypf.com>
Subject RV: Problem with Stored Procedure SQLServer + iBatis
Date Tue, 30 Oct 2007 16:33:27 GMT
Hi,
I have find the problem, but it seems a bug, because I don't find documentation about it.
 
This is my procedure, now I paste more code than yesterday:
CREATE PROCEDURE [dbo].[proc_IMPUESTOSPAGADOS_SELECT_Devuelve_DirGen_UniNegPais_Paises] 
        @chrIdioma char(2), 
        @chrUsuario varchar(25), 
        @intIdDireccionGeneral int, 
        @intIdUniNegImpPag int 

/**** MORE ***/ 

  IF @chrIdioma = 'ES'
     BEGIN
      SET @NombrePais = 'chrNombreSp as NombrePais'
     END
    ELSE IF @chrIdioma = 'EN'
     BEGIN
      SET @NombrePais = 'chrNombreEn as NombrePais'
     END
   

 SET @sentencia ='
     SELECT ImpuestosPagados_DirGen_UniNegPais.intIdPais,' +  @NombrePais  + '
     FROM ImpuestosPagados_DirGen_UniNegPais 
     INNER JOIN Paises_Paises 
     ON ImpuestosPagados_DirGen_UniNegPais.intIdPais = Paises_Paises.intIdPais
     '

                                
/***** MORE ****/ 

END 
GO 

This is my sqlMap: 

        <resultMap id="paisesPorDGPorUNResult" class="paisesMulti"> 
                <result property="intIdPais" column="intIdPais" jdbcType="INTEGER" javaType="java.lang.String"/>

                <result property="nombrePais" column="NombrePais"/> 
        </resultMap> 

        <procedure id="getPaisesPorDGPorUN" parameterClass="unidadesNegocio" resultMap="paisesPorDGPorUNResult">

                {call dbo.proc_IMPUESTOSPAGADOS_SELECT_Devuelve_DirGen_UniNegPais_Paises 
 (#strIdioma:VARCHAR#,#strUsuario:VARCHAR#,                                   #intIdDireccionGeneral:INTEGER#,#intIdUniNegImpPag:INTEGER#)}
  

        </procedure> 

This procedure works fine using jdbc, but when I execute this procedure using ibatis I have
this exception: 

Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in com/repsolypf/srf/adm/imptopag/dominio/DireccionesGenerales.xml.
 
--- The error occurred while applying a result map.  
--- Check the DireccionesGenerales.paisesPorDGPorUNResult.  
--- Check the result mapping for the 'intIdPais' property.  
--- Cause: com.microsoft.sqlserver.jdbc.SQLServerException: The column name intIdPais is not
valid. 

 
 
Changing the DB alias NombrePais to nombrePais, and changing too the column name  NombrePais
to nombrePais in the resultMap it works fine.
 
¿It's alowed for iBATIS to use column (or alias) names in database beginning by uppercase
or not?
 
I use iBATIS 2.3.0.677 whit SQLServer 2000, but using the SQLServer 2005 driver.
 
Thanks for your answer.
 
Angel Guillén


________________________________

Enviado el: martes, 30 de octubre de 2007 10:50
Para: user-java@ibatis.apache.org
Asunto: RV: Problem with Stored Procedure SQLServer + iBatis



Hello 

I have a problem mapping a stored procedure of SQL SERVER from iBATIS. 

This is my sqlMap: 

        <resultMap id="paisesPorDGPorUNResult" class="paisesMulti"> 
                <result property="intIdPais" column="intIdPais" jdbcType="INTEGER" javaType="java.lang.String"/>

                <result property="nombrePais" column="NombrePais"/> 
        </resultMap> 

        <procedure id="getPaisesPorDGPorUN" parameterClass="unidadesNegocio" resultMap="paisesPorDGPorUNResult">

                {call dbo.proc_IMPUESTOSPAGADOS_SELECT_Devuelve_DirGen_UniNegPais_Paises 
 (#strIdioma:VARCHAR#,#strUsuario:VARCHAR#,                                   #intIdDireccionGeneral:INTEGER#,#intIdUniNegImpPag:INTEGER#)}
  

        </procedure> 

The DB Server is a SQLServer 2000 but we are using the SQLServer 2005 JBDC Driver (because
it fix a bug that causes problems working with iBatis)

When I execute this procedure i have this exception: 

Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in com/repsolypf/srf/adm/imptopag/dominio/DireccionesGenerales.xml.
 
--- The error occurred while applying a result map.  
--- Check the DireccionesGenerales.paisesPorDGPorUNResult.  
--- Check the result mapping for the 'intIdPais' property.  
--- Cause: com.microsoft.sqlserver.jdbc.SQLServerException: The column name intIdPais is not
valid. 

The column name is ok when I execute this procedure from SqlServer client, this is the SP:


CREATE PROCEDURE [dbo].[proc_IMPUESTOSPAGADOS_SELECT_Devuelve_DirGen_UniNegPais_Paises] 
        @chrIdioma char(2), 
        @chrUsuario varchar(25), 
        @intIdDireccionGeneral int, 
        @intIdUniNegImpPag int 

/**** MORE ***/ 

                                        'SELECT intIdPais,' +  @NombrePais  + ' 
                                        FROM ImpuestosPagados_DirGen_UniNegPais 
                                        INNER JOIN Paises_Paises 
                                        ON ImpuestosPagados_DirGen_UniNegPais.intIdPais =
Paises_Paises.intIdPais' 
                                
/***** MORE ****/ 

END 
GO 

Do you know where is the problem? I can't see it. 

Greetings and thanks 
  
Angel Guillén 


Mime
View raw message