You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Thorsten Elfert <th...@db.com> on 2007/11/01 17:11:24 UTC
Error setting property in case of a null value - How to map correctly ?
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.
Re: Error setting property in case of a null value - How to map correctly ?
Posted by Thorsten Elfert <th...@db.com>.
Hi,
sorry, I have forgotten to mention ist: it is an int.
________________________________________
"Larry Meadors" <lm...@apache.org>
Sent by: larry.meadors@gmail.com
01.11.2007 17:40
Please respond to
user-java@ibatis.apache.org
To
user-java@ibatis.apache.org
cc
Subject
Re: Error setting property in case of a null value - How to map correctly
?
What's the java type of the value being set to null?
Larry
On 11/1/07, Thorsten Elfert <th...@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.
--
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.
Re: Error setting property in case of a null value - How to map correctly ?
Posted by Larry Meadors <lm...@apache.org>.
What's the java type of the value being set to null?
Larry
On 11/1/07, Thorsten Elfert <th...@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.
Re: Error setting property in case of a null value - How to map correctly ?
Posted by Larry Meadors <lm...@apache.org>.
You are not thinking this through. :-)
Boxing means that you can push an int value into an Integer.
Unboxing means you can pull an int value out of an Integer.
If the Integer is null, what do you pull out of it?
Try this code:
Integer i = 5; // this is boxing.
int j = i; // this is unboxing.
i = null;
j = i; // what happens here?
Larry
Re: Error setting property in case of a null value - How to map correctly ?
Posted by Thorsten Elfert <th...@db.com>.
Hi,
thanks, I just read the docs and it seems this should work anyway:
*** Primitive types such as int, boolean and float cannot be directly
supported as primitive types, as the
iBATIS Database Layer is a fully Object Oriented approach. Therefore all
parameters and results must be
an Object at their highest level. Incidentally the autoboxing feature of
JDK 1.5 will allow these primitives
to be used as well.
However, I tried the same with JDK 1.5: it still does not work. Changed
int to Integer: works.
Btw, I expected iBatis to handle this for me.
So what? Finally, It works and I'd like to thank you for your support!
Thorsten
________________________________________
"Larry Meadors" <lm...@apache.org>
Sent by: larry.meadors@gmail.com
02.11.2007 13:14
Please respond to
user-java@ibatis.apache.org
To
user-java@ibatis.apache.org
cc
Subject
Re: Error setting property in case of a null value - How to map correctly
?
Yeah, you can't set an int to null.
int x = null; // <- this won't compile
You need to either use a wrapped type (Integer) or 'magic value' (like
0) to handle null.
I'd suggest changing the type to Integer instead of int.
Larry
On 11/2/07, Thorsten Elfert <th...@db.com> wrote:
>
> thanks for the hint. I have done the changes as suggested
>
> <select id="getXYZ"
> parameterClass="int" resultMap="xyz-result" >
> <![CDATA[
> select * from XYZ
> where id = #id#
> ]]>
> </select>
>
> and I added the Java type information in the resultmap section:
>
> <result property="repurchaseFeeId"
column="REPURCHASE_FEE_ID" jdbcType="NUMERIC"/>
>
>
> However, it still get the same error:
>
> Caused by: java.lang.RuntimeException: Error setting property
'setRepurchaseFeeId' of 'XYZ ( XYZ@913842e2 .... repurchaseFeeId = 0
..... )'. Cause: java.lang.IllegalArgumentException
>
> Any ideas?
>
>
>
>
> "Nathan Maves" <na...@gmail.com>
>
> 01.11.2007 17:54
>
> Please respond to
> user-java@ibatis.apache.org
>
>
> To user-java@ibatis.apache.org
>
> cc
>
>
> Subject Re: Error setting property in case of a null value - How to map
correctly ?
>
>
>
>
>
>
>
>
> 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.
>
>
> --
>
> 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.
--
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.
Re: Error setting property in case of a null value - How to map correctly ?
Posted by Larry Meadors <lm...@apache.org>.
Yeah, you can't set an int to null.
int x = null; // <- this won't compile
You need to either use a wrapped type (Integer) or 'magic value' (like
0) to handle null.
I'd suggest changing the type to Integer instead of int.
Larry
On 11/2/07, Thorsten Elfert <th...@db.com> wrote:
>
> thanks for the hint. I have done the changes as suggested
>
> <select id="getXYZ"
> parameterClass="int" resultMap="xyz-result" >
> <![CDATA[
> select * from XYZ
> where id = #id#
> ]]>
> </select>
>
> and I added the Java type information in the resultmap section:
>
> <result property="repurchaseFeeId" column="REPURCHASE_FEE_ID" jdbcType="NUMERIC"/>
>
>
> However, it still get the same error:
>
> Caused by: java.lang.RuntimeException: Error setting property 'setRepurchaseFeeId' of 'XYZ ( XYZ@913842e2 .... repurchaseFeeId = 0 ..... )'. Cause: java.lang.IllegalArgumentException
>
> Any ideas?
>
>
>
>
> "Nathan Maves" <na...@gmail.com>
>
> 01.11.2007 17:54
>
> Please respond to
> user-java@ibatis.apache.org
>
>
> To user-java@ibatis.apache.org
>
> cc
>
>
> Subject Re: Error setting property in case of a null value - How to map correctly ?
>
>
>
>
>
>
>
>
> 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.
>
>
> --
>
> 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.
Re: Error setting property in case of a null value - How to map correctly ?
Posted by Thorsten Elfert <th...@db.com>.
thanks for the hint. I have done the changes as suggested
<select id="getXYZ"
parameterClass="int" resultMap="xyz-result" >
<![CDATA[
select * from XYZ
where id = #id#
]]>
</select>
and I added the Java type information in the resultmap section:
<result property="repurchaseFeeId" column=
"REPURCHASE_FEE_ID" jdbcType="NUMERIC"/>
However, it still get the same error:
Caused by: java.lang.RuntimeException: Error setting property
'setRepurchaseFeeId' of 'XYZ ( XYZ@913842e2 .... repurchaseFeeId = 0
..... )'. Cause: java.lang.IllegalArgumentException
Any ideas?
"Nathan Maves" <na...@gmail.com>
01.11.2007 17:54
Please respond to
user-java@ibatis.apache.org
To
user-java@ibatis.apache.org
cc
Subject
Re: Error setting property in case of a null value - How to map correctly
?
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.
--
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.
Re: Error setting property in case of a null value - How to map correctly ?
Posted by Nathan Maves <na...@gmail.com>.
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 <th...@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.