Anyone had a chance to look at this issue yet?
Nathan
On Mar 3, 2005, at 9:46 AM, Nathan Maves wrote:
Team,
I know that this was not the intended way to use CTH but it works 99% of the time!
The 1% of the time that it fails is really strange. It will only fail if the column before it in the result map is null. In the example below I can get it to work if I move the line
<result property="timeZone" column="time_zone"/>
after a result that is NOT null.
I am not sure why this is happening. I thought that the order of the result map meant nothing.
Nathan
SqlMapConfig
<typeAlias alias="TimeZone" type="giveservice.domain.definitions.TimeZone"/>
<typeHandler javaType="TimeZone" callback="giveservice.dao.ibatis.typeHandler.TimeZoneCTH"/>
CTH public class TimeZoneCTH implements TypeHandlerCallback {
public Object getResult(ResultGetter getter) throws SQLException { if (getter.wasNull()) return null; int value = getter.getInt(); return TimeZone.findEnumeration(value); }
public void setParameter(ParameterSetter setter, Object parameter) throws SQLException {
if (parameter == null) {
setter.setNull(Types.INTEGER);
} else {
TimeZone param = (TimeZone) parameter;
setter.setInt(param.getDatabaseId());
}
}
public Object valueOf(String s){ return s; }
}
ResultMap Working
<resultMap id="simpleRequestResultMap" class="Request"> <result property="id" column="id"/> ... <result property="partner" column="partner"/> <result property="partnerName" column="partner_name"/> <result property="partnerEmail" column="partner_email"/> <result property="partnerPhone" column="partner_phone"/> <result property="contractNumber" column="contract_number"/> <result property="timeZone" column="time_zone"/> ... </resultMap>
ResultMap NOT Working! < Notice the order in regards to the time_zone column >
<resultMap id="simpleRequestResultMap" class="Request"> <result property="id" column="id"/> ... <result property="partner" column="partner"/> <result property="partnerName" column="partner_name"/> <result property="partnerEmail" column="partner_email"/> <result property="partnerPhone" column="partner_phone"/> <result property="timeZone" column="time_zone"/> <result property="contractNumber" column="contract_number"/> ... </resultMap>

