ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Petr V." <greatman...@yahoo.com>
Subject SQL Mapping is not working
Date Fri, 16 Jan 2009 02:19:49 GMT
Any idea what is going on  ? :-( It is straight forward code 

==================================================

<resultMap class="Job" id="JobResult">

    <result column="JOB_ID" jdbcType="INTEGER" property="jobId" />
    <result column="STATUS" jdbcType="INTEGER" javaType="JobStatusEnum"   
             property="jobStatus" typeHandler="JobStatusEnumTypeHandlerCallback"/>

</resultMap>

==========================================

TypeHandler is 

public class JobStatusEnumTypeHandlerCallback implements TypeHandlerCallback  {

    /**
     * 
     * @param getter
     * @return
     * @throws SQLException
     */
    public Object getResult(ResultGetter getter) throws SQLException {  
       
        Integer intStatus = getter.getInt();  
        JobStatusEnum status = null;  
  
        if (intStatus != null) {  
            status = JobStatusEnum.convert(intStatus);
        }  
 
       return status;  
    }  
 
    /**
     * 
     * @param setter
     * @param parameter
     * @throws SQLException
     */
    public void setParameter(ParameterSetter setter, Object parameter) throws SQLException
{  
        JobStatusEnum status = (JobStatusEnum) parameter;  
        Integer intStatus = new Integer(status.toIntValue());  
        setter.setInt(intStatus);  
    }  
 
    /**
     * 
     * @param s
     * @return
     */
    public Object valueOf(String s) {  
        return s;  
    }  

============================================

Executing Code

Job job = new Job();
job.setId(20);
job.setStatus(JobStatusEnum.OK);

============================================

Exception Log is 

Caused by: org.firebirdsql.jdbc.field.TypeConvertionException: Error converting to int. OK
    at org.firebirdsql.jdbc.field.FBIntegerField.setString(FBIntegerField.java:124)
    at org.firebirdsql.jdbc.AbstractPreparedStatement.setString(AbstractPreparedStatement.java:402)
    at org.apache.commons.dbcp.DelegatingPreparedStatement.setString(DelegatingPreparedStatement.java:132)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.ibatis.common.jdbc.logging.PreparedStatementLogProxy.invoke(PreparedStatementLogProxy.java:70)
    at $Proxy1.setString(Unknown Source)
    at com.ibatis.sqlmap.engine.type.EnumTypeHandler.setParameter(EnumTypeHandler.java:36)
    at com.ibatis.sqlmap.engine.mapping.parameter.ParameterMap.setParameter(ParameterMap.java:166)
    at com.ibatis.sqlmap.engine.mapping.parameter.ParameterMap.setParameters(ParameterMap.java:126)
    at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeUpdate(SqlExecutor.java:78)
    at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.sqlExecuteUpdate(MappedStatement.java:216)
    at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeUpdate(MappedStatement.java:94)
    ... 31 more





      
Mime
View raw message