ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jane Phillips <jane22...@yahoo.com>
Subject 1 to N in queryForObject()
Date Mon, 31 Jul 2006 13:02:38 GMT
Hi, I am new to iBatis. I have a question for one of my query. I have tables:
  1.  Product 
      -- product_id
      -- product_description
      -- product_name
  2. Items
      -- item_id
      -- product_id
      -- item_description
      -- item_name
  The relationship is one product can have many items. query I would like to do is : 
  <select id="getProductItems" resultClass="com.abc.products">
  SELECT product_id, product_description,product_name, item_name from product a, items b WHERE
a.product_id = b.product_id and a.product_id = #id#
  in java, com.abc.products:
  String product_name;
  String product_description;
  String product_id;
  String[] item_name;
  and all the getXXX and setXXX methods.
  The goal is run this query using queryForObject() to get one product and all its items to
a products object instead of queryForList() to get collection of product object with duplicate
product_name, product_description and product_id. Is it feasible? And how to config the sqlMap
or other things to do it ?
  Please advise

See the all-new, redesigned Yahoo.com.  Check it out.
View raw message