ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher.Mathru...@sybase.com
Subject embedding existing resultMap to a resultMap
Date Wed, 22 Mar 2006 16:31:09 GMT

<br><font size=2 face="sans-serif">I think that I am missing something
here but I can't find the documentation pertaining to this.</font>
<br>
<br><font size=2 face="sans-serif">I have a BillTo class which contains
a PaymentTerms object. Of course the BillTo resultMap could read as follows:</font>
<br>
<br><font size=2>&nbsp; &nbsp; &nbsp; &nbsp; </font><font
size=2 color=blue>&lt;</font><font size=2 color=#800000>result</font><font
size=2 color=red>
column</font><font size=2 color=blue>=&quot;</font><font size=2>payment_terms_code</font><font
size=2 color=blue>&quot;</font><font size=2 color=red>
property</font><font size=2 color=blue>=&quot;</font><font size=2>paymentTerms</font><font
size=2 color=blue>&quot;</font><font size=2 color=red>
select</font><font size=2 color=blue>=&quot;</font><font size=2>PaymentTerms-findByPrimaryKey</font><font
size=2 color=blue>&quot;/&gt;</font>
<br>
<br><font size=2 face="sans-serif">But doing this causes the select to
be fired for every billTo object returned. So I flattened it out by joining
the two tables, and this works fine.</font>
<br>
<br><font size=2>&nbsp; &nbsp; </font><font size=2 color=blue>&lt;</font><font
size=2 color=#800000>result</font><font size=2 color=red>
column</font><font size=2 color=blue>=&quot;</font><font size=2>payment_terms_code</font><font
size=2 color=blue>&quot;</font><font size=2 color=red>
property</font><font size=2 color=blue>=&quot;</font><font size=2>paymentTerms.code</font><font
size=2 color=blue>&quot;</font><font size=2 color=red>
</font><font size=2 color=blue>/&gt;</font>
<br><font size=2>&nbsp; &nbsp;</font><font size=2 color=blue>&lt;</font><font
size=2 color=#800000>result</font><font size=2 color=red>
column</font><font size=2 color=blue>=&quot;</font><font size=2>payment_mess</font><font
size=2 color=blue>&quot;</font><font size=2 color=red>
property</font><font size=2 color=blue>=&quot;</font><font size=2>paymentTerms.description</font><font
size=2 color=blue>&quot;</font><font size=2 color=red>
</font><font size=2 color=blue>/&gt;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp;
...</font>
<br>
<br><font size=2 face="sans-serif">But now my problem is that I am maintaining
two resultMaps for the same object, one in PaymentTerms.xml and one in
BillTo.xml. So I wanted to use the resultMap defined in PaymentTerms.xml
and I found the resultMap attribute on the result element, so I thought
I could define my BillTo resultMap as follows:</font>
<br>
<br><font size=2>&nbsp; </font><font size=2 color=blue>&lt;</font><font
size=2 color=#800000>result</font><font size=2 color=red>
property</font><font size=2 color=blue>=&quot;</font><font size=2>paymentTerms</font><font
size=2 color=blue>&quot;</font><font size=2 color=red>
resultMap</font><font size=2 color=blue>=&quot;</font><font size=2>PaymentTerms.PaymentTermsResult</font><font
size=2 color=blue>&quot;</font><font size=2 color=red>
</font><font size=2 color=blue>/&gt;</font>
<br>
<br><font size=2 face="sans-serif">But this causes an Exception to be thrown.</font>
<br>
<br><font size=2 face="Courier New">08:20:03,594 ERROR [http-8080-Processor24]
- SqlMapClient operation; uncategorized </font><font size=2 color=#000080 face="Courier
New"><u>SQLException</u></font><font size=2 face="Courier New">
for SQL []; SQL state [null]; error code [0]; &nbsp; </font>
<br><font size=2 face="Courier New">--- The error occurred in com/sybase/cosmos/dao/maps/BillTo.xml.
&nbsp;</font>
<br><font size=2 face="Courier New">--- The error occurred while applying
a result map. &nbsp;</font>
<br><font size=2 face="Courier New">--- Check the BillTo.BillToResult.
&nbsp;</font>
<br><font size=2 face="Courier New">--- The error happened while setting
a property on the result object. &nbsp;</font>
<br><font size=2 face="Courier New">--- Cause: </font><font size=2 color=#000080
face="Courier New"><u>com.ibatis.sqlmap.client.SqlMapException</u></font><font
size=2 face="Courier New">:
Error instantiating collection property for mapping 'paymentTerms'. &nbsp;Cause:
</font><font size=2 color=#000080 face="Courier New"><u>java.lang.ClassCastException</u></font>
<br><font size=2 face="Courier New">Caused by: java.lang.ClassCastException;
nested exception is </font><font size=2 color=#000080 face="Courier New"><u>com.ibatis.common.jdbc.exception.NestedSQLException</u></font><font
size=2 face="Courier New">:
&nbsp; </font>
<br>
<br>
<br><font size=2 face="sans-serif">So am I missing something or am I just
trying to do something that is not supported?</font>
<br>
<br><font size=2 face="sans-serif">Thanks for the help....</font>
<br><font size=2 face="sans-serif"><br>
Chris Mathrusse<br>
christopher.mathrusse@sybase.com<br>
Sybase, Inc<br>
One Sybase Drive<br>
Dublin, CA 94568<br>
(925) 236-5553</font>

Mime
View raw message