This usually occurs when you are trying to stuff a DB null-value into a
primitive Java field. You can either:

-          change DB data

-          change primitive type into wrapper, i.e. int -> Integer

-          use the magic nullValue attribute, personally I don't like
this one

 

Niels

________________________________

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Monday, January 07, 2008 6:14 PM
To: user-java@ibatis.apache.org
Subject: Error setting a property: IllegalArgumentException

 


Hi all 

iBatis reports the following exception trace 

--- The error occurred in
it/finmatica/gpj/aa/frontedb/EspressioneFabbricaImpl.xml.   
--- The error occurred while applying a result map.   
--- Check the Gpj.mapEspressioneValoriTipoRigaMulti.   
--- The error happened while setting a property on the result object.   
--- Cause: com.ibatis.common.exception.NestedRuntimeException: Error
setting properties of
'[EMAIL PROTECTED]'.  Cause:
java.lang.IllegalArgumentException 
Caused by: java.lang.IllegalArgumentException 
Caused by: com.ibatis.common.exception.NestedRuntimeException: Error
setting properties of
'[EMAIL PROTECTED]'.  Cause:
java.lang.IllegalArgumentException 
Caused by: java.lang.IllegalArgumentException 
        at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQuery
WithCallback(GeneralStatement.java:188) 
        at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQuery
ForList(GeneralStatement.java:123) 
        at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMap
ExecutorDelegate.java:610) 
        at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMap
ExecutorDelegate.java:584) 
        at
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessi
onImpl.java:101) 
        at
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForList(SqlMapClient
Impl.java:78) 
        at
it.finmatica.gpj.ec.istruzioni.EspressioneFabbricaImpl.getOggettiImpl(Es
pressioneFabbricaImpl.java:183) 
        at
it.finmatica.gpj.aa.frontedb.InitFogliaFabbricaImpl.getOggettiImpl(InitF
ogliaFabbricaImpl.java:119) 
        at
it.finmatica.gpj.aa.frontedb.InitFabbricaImpl.getOggetti(InitFabbricaImp
l.java:61) 
        at
it.finmatica.gpj.ec.istruzioni.EspressioneFabbricaImplTest.testGetOggett
i(EspressioneFabbricaImplTest.java:87) 
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
Source) 
        at java.lang.reflect.Method.invoke(Unknown Source) 
        at junit.framework.TestCase.runTest(TestCase.java:164) 
        at junit.framework.TestCase.runBare(TestCase.java:130) 
        at junit.framework.TestResult$1.protect(TestResult.java:110) 
        at junit.framework.TestResult.runProtected(TestResult.java:128) 
        at junit.framework.TestResult.run(TestResult.java:113) 
        at junit.framework.TestCase.run(TestCase.java:120) 
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
stRunner.java:478) 
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRun
ner.java:344) 
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRu
nner.java:196) 
        ... 


Here is the Gpj.mapEspressioneValoriTipoRigaMulti map 

        <resultMap id="mapEspressioneValoriTipoRigaMulti"
class="it.finmatica.gpj.ec.istruzioni.EspressioneStruct"> 
                <result property="id" column="VALORE_ID"
jdbcType="NUMERIC" javaType="int"/> 
                <result property="idIdentificatore"
select="Gpj.selectIdIdentificatore" column="FORMULA_ID" javaType="int"/>

                <result property="idPeriodoNormativo"
select="Gpj.selectIdPeriodoNormativo" column="FORMULA_ID"
javaType="int"/> 
                <result property="idTipo" select="Gpj.selectIdTipoCampo"
column="TIPO_RIGA_ID" javaType="int"/> 
                <result property="nome" select="Gpj.selectNomeCampo"
column="TIPO_RIGA_ID" javaType="java.lang.String"/>         
                <result property="testo" column="TESTO"
jdbcType="VARCHAR" javaType="java.lang.String"/> 
        </resultMap> 


Is there any way to interpret the (not so well understandable)
diagnostic 

Error setting properties of
'[EMAIL PROTECTED]'. 

Which property of the EspressioneStruct is involved? Looking to the log
I could note what follows: 

The last prepared stament that has been printed in the log is 

DEBUG [main] - {pstm-139524} PreparedStatement:    select NOME   from
TIPI_DATO_RIGA   where TIPO_RIGA_ID = ?   
DEBUG [main] - {pstm-139524} Parameters: [21] 
DEBUG [main] - {pstm-139524} Types: [java.math.BigDecimal] 

That query do correspond to the so called  selectNomeCampo query and is
used to set the nome property of the EspressioneStruct (see above). 

        <select id="selectNomeCampo" resultClass="java.lang.String"> 
                select NOME 
                from TIPI_DATO_RIGA 
                where TIPO_RIGA_ID = #id:INTEGER# 
        </select> 

The raised exception
<http://java.sun.com/j2se/1.4.2/docs/api/java/lang/IllegalArgumentExcept
ion.html>   (java.lang.IllegalArgumentException) would seem indicate a
problem with the argument. 

#id:INTEGER# should be initalized wqith the value of the TIPO_RIGA_ID
column, that is decalred as NUMBER(10) ad has value 21 (exactly as
reported in the log). 

Before of that record, dozens of other ones are successfully loaded,
exerting well both the nome propperty and its selectNomeCampo setter. 

Provided that nome and selectNomeCampo actually are the involved
entities (I guess so) frankly it would seem everything pretty in order. 
TIPO_RIGA_ID is a column that is not explicitly assigned to any
property, but I saw that this is a quite common practice
I'm getting confused. 


Any suggestion?
Thanks in advance 

ciao 
Cesare

Reply via email to