> I'm trying to populate a pojo with two array lists and my code doesn't do > what I intended > > The pojo has two arrayLists as memebers one called 'dates' the other > 'values'
Why can't you create class DateValuePair { private Date date; private Double value; ... getter, setter } and query for List<DateValuePair>? > The mapper XML file I have set up looks like this > > <?xml version="1.0" encoding="UTF-8"?> > <!DOCTYPE mapper > PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN" > "http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd"> > <mapper namespace="com.aimhedge.trading.database.BackAdjFutureMapper"> > <resultMap id="futureMap" type="DataMap"> > <collection property="dates" javaType="ArrayList" ofType="Date"> > <id property="date" column="date" javaType="Date" > jdbcType="DATE"/> > </collection> > <collection property="values" javaType="ArrayList" > ofType="Double"> > <id property="value" column="value" javaType="Double" > jdbcType="DOUBLE"/> > </collection> > </resultMap> > <select id="selectBackAdjFuture" parameterType="BackAdjFuture" > resultMap="futureMap"> > select date, value > from back_adj_future > where feed = #{feed} > and instrument = #{instrument} > and periodicity = #{periodicity} > and field = #{field} > and date <![CDATA[<]]> str_to_date('19980721','%Y%m%d') > and date <![CDATA[>]]> str_to_date('19980701','%Y%m%d') > </select> > </mapper> Example in iBATIS 2 syntax (I'm not familiar with iBATIS 3): <resultMap id="futureMap" resultClass="com...DateValuePair"> <result property="date" column="date" jdbcType="DATE"> <result property="value" column="value" jdbcType="NUMERIC"> </resultMap> <select id="selectBackAdjFuture" parameterClass="BackAdjFuture" resultMap="futureMap"> SELECT date, value FROM back_adj_future WHERE feed = #feed# AND instrument = #instrument# AND periodicity = #periodicity# AND field = #field# AND str_to_date('19980721', '%Y%m%d') > date AND date > str_to_date('19980701', '%Y%m%d') </select> (You can avoid the CDATA sections "inverting" the "<" to ">".) > When I run the code, instead of having both one array list populated with > dates and the other with values both seem to contain dates. Can anyone point > out where I am going wrong? I'm new to iBatis and my use of collections is > probably wrong. One of my issues is that the value field isn't unique so > setting it as an id is probably wrong. If you can't avoid the representation of your data using class DataMap then write a few lines and create the instance outside iBATIS based on the List<DateValuePair>. Also seems, that you can use BackAdjFuture instead of the additional class DateValuePair. Another approach is to use HashMap as result class. --------------------------------------------------------------------- To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org For additional commands, e-mail: user-java-h...@ibatis.apache.org