ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jozef Hribik <jozef.hri...@apsoft.sk>
Subject Re: [Fwd: How to pass a parameter to collection property?]
Date Mon, 05 Dec 2005 07:51:57 GMT
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
  <title></title>
</head>
<body style="color: rgb(0, 0, 0); font-family: Arial;" bgcolor="#ffffff"
 text="#000000">
Thank you Jeff, i am using your solution already, but i want to get <b>_categories_with_products_</b>
in single step.<br>
 <br>
<div>Map map = new HashMap();</div>
<div>map.put("parameterY", parameterY);</div>
<div>
<div>map.put("parameterX", parameterX);</div>
<div>List results = sqlMap.queryForList("getCategory", map);</div>
</div>
<br>
&lt;statement id=”getCategory” parameterClass=”int”
resultMap=”get-category-result”&gt;<br>
select * from CATEGORY where CAT_DESCRIPTION like  '%$<b>parameterY</b>$%'<br>
&lt;/statement&gt;<br>
<br>
&lt;statement id="getProductsByCatId" parameterClass="int"
resultMap="get-product-result"&gt;
<br>
select * from PRODUCT where PRD_CAT_ID = #value# and PRD_PRICE = <b>#parameterX#</b><br>
&lt;/statement&gt;<br>
<br>
Is it possible or is it a new feature request ?<br>
<br>
<br>
<br>
Jeff Butler wrote:<br>
<blockquote
 cite="midc593b8750512020724h4dcfcf81lc2e3d5369b111007@mail.gmail.com"
 type="cite">
  <div>Here's how to do it with a map:</div>
  <div> </div>
  <div>Map map = new HashMap();</div>
  <div>map.put("parameterY", parameterY);</div>
  <div>
  <div>map.put("parameterX", parameterX);</div>
  <div>List results = sqlMap.queryForList("getProductsByCatId", map);</div>
  </div>
  <div> </div>
  <div> </div>
  <div>&lt;<strong>select</strong> id="getProductsByCatId"
parameterClass="<strong>java.util.Map</strong>"
resultMap="get-product-result"&gt;<br>
select * from PRODUCT where PRD_CAT_ID = #<strong>parameterY</strong>#
and PRD_PRICE = <b>#parameterX#</b><br>
&lt;/<strong>select</strong>&gt;<br>
 </div>
  <div>You could also do it with a POJO as your parameter class (which
is preferred) - the properties in the select statement correspond to
properties in your POJO.</div>
  <div> </div>
  <div>Jeff Butler<br>
  <br>
 </div>
  <div><span class="gmail_quote">On 12/2/05, <b
 class="gmail_sendername">Jozef Hribik</b> &lt;<a
 href="mailto:jozef.hribik@apsoft.sk">jozef.hribik@apsoft.sk</a>&gt;
wrote:</span>
  <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left:
1ex;">I
would like to pass an additional parameter to filter a collection
property.<br>
I will use an example from iBATIS-SqlMaps-2.pdf, page 27.<br>
 <br>
How can i select a category with products with certain price specified
by parameterX?<br>
 <br>
&lt;resultMap id="get-category-result"
class="com.ibatis.example.Category"&gt;<br>
&lt;result property="id" column="CAT_ID"/&gt;
    <br>
&lt;result property="description" column="CAT_DESCRIPTION"/&gt;<br>
&lt;result property="productList" column="CAT_ID"
select="getProductsByCatId"/&gt;<br>
&lt;/resultMap&gt;<br>
    <br>
&lt;statement id="getProductsByCatId" parameterClass="int"
resultMap="get-product-result"&gt;
    <br>
select * from PRODUCT where PRD_CAT_ID = #value# and PRD_PRICE = <b>#parameterX#</b><br>
&lt;/statement&gt;<br>
    <br>
Thanks<br>
    <span class="sg">Jozef<br>
    </span></blockquote>
  </div>
  <br>
</blockquote>
<br>
</body>
</html>

Mime
View raw message