ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c.ze...@ads.it
Subject static checking of the inline parameters
Date Tue, 21 Nov 2006 08:26:08 GMT





> causes the following diagnostic
>

> --- The error occurred in it/finmatica/gpj/aa/frontebd/TipoRiga.xml.
> --- The error occurred while executing update procedure.
> --- Check the {? = call tipo_dato_riga.exists_id( ? ) }.
> --- Check the output parameters (register output parameters failed).
> --- Cause: java.sql.SQLException : Invalid column type
> Caused by: java.sql.SQLException : Invalid column type
> at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(
> GeneralStatement.java:91)

[...]

Well, I would spend a few words on the reason of the problem.
I have a micro unit tester class whose purpose is only to load the
sql-map-config.xml and the other "resource" SQL map XML files to check
their correctness.
If there is some error, iBatis raises its exception and the test fails.
Success of the test means that the SQL maps are correct and can be loaded.
That test worked fine with jdbcType=NUMBER.
So, I guessed (wrongly) that the problem was elsewhere.

To cut short: the diagnostic does not help.
Which column has invalid type?
What about a static type checking of  the type conversion constants defined
by java.sql.Types class and used in the inline parameters?
It would be a good enhancement!


Regards.


Cesare




                                                                           
             "Jeff Butler"                                                 
             <jeffgbutler@gmai                                             
             l.com>                                                    Per 
                                       user-java@ibatis.apache.org         
             20/11/2006 17:24                                           CC 
                                                                           
                                                                   Oggetto 
                Per favore,            Re: stored function: NUMBER result, 
               rispondere a            NUMBER IN parameter                 
             user-java@ibatis.                                             
                apache.org                                                 
                                                                           
                                                                           
                                                                           
                                                                           




NUMBER is not a valid JDBC Type (it is Oracle specific).  See here for the
valid options:

http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Types.html


Jeff Butler


On 11/20/06, c.zecca@ads.it <c.zecca@ads.it> wrote:


      The TIPO_DATO_RIGA package declares the following overloaded versions
      of the exists_id() method in its interface

         function  exists_id
        ( p_tipo_riga_ID  in number(10)
        ) return  number;
        pragma restrict_references ( exists_id, WNDS );

         function  exists_id
        ( p_tipo_dato_ID  in number(10)
        , p_nome          in  varchar2(30)
        ) return number;
        pragma restrict_references( exists_id, WNDS  );


      Here is the SQL map

      <procedure id="esisteTipoRiga" parameterClass=" java.util.Map">
       {#result,mode=OUT,javaType=java.lang.Integer,jdbcType=NUMBER# = call
      tipo_dato_riga.exists_id( # pId
      ,javaType=java.lang.Integer,jdbcType=NUMBER,mode=IN# ) }
      </procedure>

      and the Java code that calls it

      SqlMapClient lSqlMapClient = Configurazione.getSqlMapIstanza();

          Integer lInteger;
          HashMap< String, Integer > lHashMap = new HashMap< String,
      Integer >();
          lHashMap.put( "pId", new Integer( 1234 ) );

              try
              {
              lSqlMapClient.update( "esisteTipoRiga", lHashMap );
              }
              catch (SQLException pException)
              {
              pException.printStackTrace();
              throw pException;
              }
          lInteger = lHashMap.get( "result" );
             boolean lResult = lInteger.intValue() == 1;

      causes the following diagnostic

      --- The error occurred in it/finmatica/gpj/aa/frontebd/TipoRiga.xml.

      --- The error occurred while executing update procedure.
      --- Check the {? = call tipo_dato_riga.exists_id( ? ) }.
      --- Check the output parameters (register output parameters failed).

      --- Cause: java.sql.SQLException : Invalid column type
      Caused by: java.sql.SQLException : Invalid column type
      at
      com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(
       GeneralStatement.java:91)
      at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.update(
      SqlMapExecutorDelegate.java:500)
      at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.update(
      SqlMapSessionImpl.java:85)

      Please note that the following PL/SQL

      declare
      lId number;
      lResult number ;
      begin
      lId := 1234 ;
      lResult := tipo_dato_riga.exists_id( lId );
      dbms_output.put_line( 'here we are...' );
      dbms_output.put_line( 'lId = ' || lId || ', lResult = ' || lResult );

      end;

      works fine.
      What's wrong in the SQL map / java code?
      Any hint?
      Is there any simpler approach on the Java side?

      Thanks in advance





Mime
View raw message