Is this even a valid way to get a hashmap or do we need to use queryForMap?
<resultMap id="foodAttributes " class="java.util.HashMap" > <result property="name" column="name"/> <result property="value" column="value"/> </resultMap> <select id="getFoodAttributes" resultMap="foodAttributes" parameterClass="int"> select * from food_attributes where food_id=#id# </select> From: Danny Lin [mailto:[EMAIL PROTECTED] Sent: Thursday, April 03, 2008 10:31 AM To: user-java@ibatis.apache.org Subject: n+1 selects and queryForMap Hello, I have an object with a property that is a HashMap of name/value pairs from a separate data table. If one of my properties on the 'food' class is a hashmap, I'm assuming I can create that hashmap using the following sql mapping correct? Is it possible to avoid the n+1 select issue and solve this problem using another method? Would this be a case to use a row handler? Thanks! food food_id int food_name varchar(256) food_attributes food_id int name varchar(64) value varchar(64) <resultMap id="food" class="food" > <result property="foodId" column="food_id"/> <result property="foodName" column="food_name"/> <result property="foodAttributes" select="getFoodAttributes"/> </resultMap> <resultMap id="foodAttributes " class="java.util.HashMap" > <result property="name" column="name"/> <result property="value" column="value"/> </resultMap> <select id="getFood" resultMap="food" parameterClass="int"> select * from food where food_id=#id# </select> <select id="getFoodAttributes" resultMap="foodAttributes" parameterClass="int"> select * from food_attributes where food_id=#id# </select> Danny