I know this question is asked many times and I still get problems when I follow the guide when including multiple parameters in my select query. Here is my configuration file:
<select id="selectByDate" parameterType="map" resultMap="campaignStats">
SELECT * FROM CampaignStats WHERE statsDate >= #{start} AND statsDate <= #{end}
</select>
Here is my Java code:
public List<DpCampaignStats> selectByDate(Date start, Date end){
SqlSession session = sqlSessionFactory.openSession();
try {
Map<String, Date> map = new HashMap<String, Date>();
map.put("start", start);
map.put("end", end);
List<DpCampaignStats> list = session.selectList("DpCampaignStats.selectByDate", map);
return list;
} finally {
session.close();
}
}
But I get the error: java.lang.ExceptionInInitializerError which means that I have some errors in my configuration file and I cannot find the reason.
Best Answer
Just wrap you SQL statement in CDATA: