You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by araoko <ol...@gmail.com> on 2009/09/08 13:12:41 UTC

problems with collection element

i have a problem with the collection element, i cant get it to populate
ArraList properties on my POJO.

i can instantiate the pojo using the constructor element but the collection
element did not work. the 
mapper configuration xml is below, and folowing it is my POJO



<mapper namespace="timetable.dao.TimeTableDAO">

<select id="selectPeriodSet" parameterType="String"
resultMap="periodSetResultMap">
  select a.name as name,
  a.startTime as startTime,
  a.endTime as endTime,
  count(b.name) as maxPeriodCount,
  from periodSets as a join periodTemplates as b on a.name=b.name
  where a.name = #{name}
</select> 

<select id="selectStartTimes" parameterType="String">
     select startTime from periodTemplates where name = #{name}
</select> 

<select id="selectEndTimes" parameterType="String">
    select endTime from periodTemplates where name = #{name}
</select> 

<resultMap type="PeriodSet" id="periodSetResultMap">

  <constructor>
    <arg column="name" javaType="String" /> 
    <arg column="startTime" javaType="SchoolTime" jdbcType="INTEGER" /> 
    <arg column="endTime" javaType="SchoolTime" jdbcType="INTEGER" /> 
    <arg column="maxPeriodCount" javaType="int" /> 
  </constructor>

  <collection property="startTimes" column="name" ofType="SchoolTime"
select="selectStartTimes" javaType="ArrayList" /> 

  <collection property="endTimes" column="name" ofType="SchoolTime"
select="selectEndTimes" javaType="ArrayList" /> 

 </resultMap>
 </mapper>

public class PeriodSet {

             private String name;
	private SchoolTime startTime;
	private SchoolTime endTime;
	private Weekday[] days;
	private List<SchoolTime> startTimes;
	private List<SchoolTime> endTimes;
	
	public PeriodSet(String name, SchoolTime startTime, SchoolTime endTime,
Integer maxPeriodCount) {
		// constuctor body
	}

//other methods
}



i created an typeHandler for the SchoolTime object too.

on inspecting the sql server logs, it showd that the select querry meant to
populate the properties are called but the size of the array list is still
zero instead of 8 as returned by the query when done manually.
what am i doing wrong?
-- 
View this message in context: http://www.nabble.com/problems-with-collection-element-tp25344158p25344158.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org