ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nathan Maves" <nathan.ma...@gmail.com>
Subject Re: Error setting property in case of a null value - How to map correctly ?
Date Thu, 01 Nov 2007 16:54:09 GMT
Not sure if this will correct your issue but you should only use a resultMap
OR a resultClass not both.

Nathan

On Nov 1, 2007 10:11 AM, Thorsten Elfert <thorsten.elfert@db.com> wrote:

>
> Hi,
>
> I am new on iBatis and I try to map an Oracle 9i based result and get the
> following error:
>
> Caused by: *java.lang.RuntimeException*: Error setting property
> 'setRepurchaseFeeId' of XYZ ( XYZ@913842e2    repurchaseFeeId = 0
>  targetGroupId = 0    offerFeeId = 0    offerId = null    transferToDo =
> FALSE    salesInfoId = 0    minimumQuota = 0    validFrom = null
>  quotaIsPublic = FALSE    ovwAdditionalInfo = null     )'.  Cause: *
> java.lang.IllegalArgumentException*
>         at
> com.ibatis.sqlmap.engine.accessplan.PropertyAccessPlan.setProperties(*
> PropertyAccessPlan.java:52*)
>         at com.ibatis.sqlmap.engine.exchange.JavaBeanDataExchange.setData(
> *JavaBeanDataExchange.java:115*)
>         at
> com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.setResultObjectValues
> (*BasicResultMap.java:373*)
>         at
> com.ibatis.sqlmap.engine.mapping.statement.RowHandlerCallback.handleResultObject
> (*RowHandlerCallback.java:64*)
>         at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(*
> SqlExecutor.java:376*)
>         at
> com.ibatis.sqlmap.engine.execution.SqlExecutor.handleMultipleResults(*
> SqlExecutor.java:295*)
>         at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(*
> SqlExecutor.java:186*)
>         at
> com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteQuery
> (*GeneralStatement.java:205*)
>         at
> com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback
> (*GeneralStatement.java:173*)
>         ... 38 more
> Caused by: *java.lang.IllegalArgumentException*
>         at
> com.ibatis.sqlmap.engine.accessplan.PropertyAccessPlan.setProperties(*
> PropertyAccessPlan.java:46*)
>
> It is based on the following select…
>
> <select id="getXYZ"
>         resultClass="XYZ"
>         parameterClass="int" resultMap="xyz-result">
>         <![CDATA[
>                 select * from XYZ
>                 where id = #id#
>         ]]>
> </select>
>
> ..and the following result map definition:
>
> <resultMap class="XYZ"
>         id="xyz-result">
>         <result property="repurchaseFeeId" column="REPURCHASE_FEE_ID" />
>         <result property="pretaxYieldCalculation"
>                 column="PRETAX_YIELD_CALCULATION" />
> …
> </resultMap>
>
>
> …an XML gets succesfully generated via:
>
> <select id="getSecurityOfferInfoByIdAsXml" resultClass="xml"
>         parameterClass="int" xmlResultName="securityOfferInfo-dummy">
>
>         <![CDATA[
>                 select * from XYZ
>                 where id = #id#
>         ]]>
> </select>
>
> Here is the result:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xzy>
>         <SECURITY_ID>88888888</SECURITY_ID>
>         <TARGET_GROUP_ID>1</TARGET_GROUP_ID>
>         <OFFER_ID>O1</OFFER_ID>
>         <REPURCHASE_ID>R9</REPURCHASE_ID>
>         <TRANSFER_TO_DO>FALSE</TRANSFER_TO_DO>
>         <QUOTA_IS_PUBLIC>FALSE</QUOTA_IS_PUBLIC>
>         <USE_GENERATED_TEXT>FALSE</USE_GENERATED_TEXT>
>         <YIELD_CALCULATION>FALSE</YIELD_CALCULATION>
>         <PRETAX_YIELD_CALCULATION>FALSE</PRETAX_YIELD_CALCULATION>
>         <VALID_FROM>2007-11-01 11:06:23.0</VALID_FROM>
> </xyz>
>
> All the null values are not part of the xml. As expected!
>
> However, the java class cannot be instantiated (as you can see in the
> exception above)
>
> For testing purposes I changed the entries in the result map like that:
>
>         <result property="repurchaseFeeId" column="REPURCHASE_FEE_ID"
> nullValue="0"/>
>
>
> This works! But this workaround is not acceptable. I do not want to get
> some value instantiated if it is null in the corresponding database
> attribute.
> The property should simply not being set!
>
> Could somebody help me on that?
>
>
> Thanks in advance!!
> --
>
> Informationen (einschließlich Pflichtangaben) zu einzelnen, innerhalb der
> EU tätigen Gesellschaften und Zweigniederlassungen des Konzerns Deutsche
> Bank finden Sie unter *http://www.db.com/de/content/pflichtangaben.htm*.
> Diese E-Mail enthält vertrauliche und/ oder rechtlich geschützte
> Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail
> irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und
> vernichten Sie diese E-Mail. Das unerlaubte Kopieren sowie die unbefugte
> Weitergabe dieser E-Mail ist nicht gestattet.
>
> Please refer to *http://www.db.com/en/content/eu_disclosures.htm* for
> information (including mandatory corporate particulars) on selected Deutsche
> Bank branches and group companies registered or incorporated in the European
> Union. This e-mail may contain confidential and/or privileged information.
> If you are not the intended recipient (or have received this e-mail in
> error) please notify the sender immediately and delete this e-mail. Any
> unauthorized copying, disclosure or distribution of the material in this
> e-mail is strictly forbidden.

Mime
View raw message