ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tony Qian" <daqiqi...@aol.com>
Subject composite key mapping problem
Date Fri, 06 Jan 2006 19:18:30 GMT
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title></title>
</head>
<body>
<font size="2"><font face="Arial,sans-serif">All,<br>
<br>
I'm new to iBATIS (like it!). I followed the example in " iBATIS DAta
MApper Developer Guide". I made it work for select based on single
column (for example selectElements based on single column). but I got
into one problem with multi columns. Here is my map file. (sorry for
complexity).<br>
<br>
&nbsp;&lt;typeAlias alias="clientSession"
type="session.SimpleClientSessionInfo"/&gt;<br>
&nbsp; &lt;typeAlias alias="parameter"
type="session.SimpleSessionParameter"/&gt;<br>
&nbsp; &lt;typeAlias alias="client" type="session.SimpleClient"/&gt;<br>
&nbsp; &lt;typeAlias alias="element"
type="session.SimpleSessionParameterElement"/&gt;<br>
&nbsp; <br>
&nbsp; &lt;resultMap id="select-sessionClient" class="clientSession"&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp; &lt;result property="brandId" column="brand_id"
/&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp; &lt;result property="client" column="{brandId=brand_id,
version=version_number}" select="selectClient" /&gt; <br>
&nbsp;&nbsp;&nbsp; &nbsp; &lt;result property="parameters" column="{brandId=brand_id,
version=version_number}" select="selectElements" /&gt;<br>
&nbsp; &lt;/resultMap&gt;<br>
<br>
&nbsp; &lt;resultMap id="select-element" class="element"&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp; &lt;result property="value" column="parameter_value"
/&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp; &lt;result property="parameter" column="parameter_id"
select="selectParameter" /&gt;<br>
&nbsp; &lt;/resultMap&gt;<br>
<br>
&nbsp; &lt;resultMap id="select-parameter" class="parameter"&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp; &lt;result property="parameterId" column="parameter_id"
/&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp; &lt;result property="name" column="parameter_name"/&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp; &lt;result property="description" column="description"/&gt;<br>
&nbsp; &lt;/resultMap&gt;<br>
&nbsp; <br>
&nbsp; &lt;resultMap id="select-client" class="client"&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp; &lt;result property="brandId" column="brand_id"
/&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp; &lt;result property="version" column="version_number"/&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp; &lt;result property="isDefault" column="is_default"/&gt;<br>
&nbsp; &lt;/resultMap&gt;<br>
&nbsp; <br>
&nbsp; &lt;statement id="selectElements" resultMap="select-element"&gt;<br>
&nbsp;&nbsp;&nbsp; select * from SESSION_INFO_PER_CLIENT where brand_id=#brandId#
and
version_number=#version#<br>
&nbsp; &lt;/statement&gt;<br>
&nbsp; <br>
&nbsp; &lt;statement id="selectClient" resultMap="select-client"&gt;<br>
&nbsp;&nbsp;&nbsp; select * from CLIENT_VERSION where brand_id=#brandId# and
version_number=#version#<br>
&nbsp; &lt;/statement&gt;<br>
<br>
&nbsp; &lt;statement id="selectParameter" parameterClass="string"
resultMap="select-parameter"&gt;<br>
&nbsp;&nbsp;&nbsp; select * from SESSION_PARAMETER where parameter_id=#parameterId#<br>
&nbsp; &lt;/statement&gt;<br>
<br>
&nbsp; &lt;statement id="getClientSessionInfoList"
resultMap="select-sessionClient"&gt;<br>
&nbsp;&nbsp;&nbsp; select DISTINCT brand_id, version_number from
SESSION_INFO_PER_CLIENT <br>
&nbsp; &lt;/statement&gt;<br>
<br>
&nbsp; &lt;statement id="getClientSessionInfo" parameterClass="map"
resultMap="select-sessionClient"&gt;<br>
&nbsp;&nbsp;&nbsp; select DISTINCT brand_id, version_number from
SESSION_INFO_PER_CLIENT having brand_id=#brandId# and
version_number=#version#<br>
&nbsp; &lt;/statement&gt;<br>
<br>
Everything worked&nbsp; fine, but the client and parameters (list) are empty
in the final object, clientSession. looks like the brandId and version
were not passed into selectClient and selectElements.<br>
<br>
appreciate your input.<br>
<br>
Tony<br>
<br>
</font></font>
</body>
</html>


Mime
View raw message