Hi Jeff, Thanks for your proposed solution. It looks very promising and it should work, but it doesn't. I got the same error. I also had my co-worker try it on different table with different test case, it also failed.
The problem was seen using 2.3.0 release. I downloaded 2.3.3 beta version and the problem disappeared. I would be happy to try any other solutions you can think of. In the mean time, I'll move foward with 2.3.3 Beta. Hope that 2.3.3 will be official release very soon. Thanks Doug ----- Original Message ---- From: Jeff Butler <[EMAIL PROTECTED]> To: user-java@ibatis.apache.org Sent: Thursday, July 31, 2008 6:56:14 PM Subject: Re: Problem using SelectByExample with TypeHandlerCallback Try this column override in your (i)abatorConfig: <columnOverride column="LOCATION_TYPE" javaType="LocationType" typeHandler="LocationTypeTypeHandler" /> This will cause (i)abator to generate code that explicitly calls the type handler. I'm fairly certain this will solve the problem. Without this, then we're possibly dealing with a limitation in iBATIS. The ByExample dynamic SQL is very complex and I don't think iBATIS is able to do as much runtime introspection to resolve the type handler as is needed here. Jeff Butler On Thu, Jul 31, 2008 at 11:10 AM, Doug Flex <[EMAIL PROTECTED]> wrote: Hi, I have a problem with Null Pointer Exception when trying to use SelectByExample with enum criteria. I have done the following to seek for answer but have no success yet. Please help! - google - looked through iBatis FAQ - looked through iBatis WIKI - looked thought iBatis mailing archive the code described below omits full package path for readability ------------------ 1) I specified type conversion for a column in AbatorConfig.xml. This generated code with the VARCHAR mapped to Java enum LocationType correctly. The generated code was Java 5, Spring Dao style.. <table tableName="LOCATION"> <columnOverride column="LOCATION_TYPE" javaType="LocationType"/> </table> 2) I have a class that called LocationTypeTypeHandler which implement TypeHandlerCallback to map database VARCHAR to Java enum LocationType 3) I specified the usage of the callback in SQLMapConfig.xml as follows: <typeHandler javaType="LocationType" jdbcType="VARCHAR" callback="LocationTypeTypeHandler"/> 4) Most of the cases such as SelectByPrimimaryKey, insert, etc...seems to be working. So, I know that my enum type conversion using LocationTypeTypeHandler was configured and invoked correctly. The problem I ran into was when using SelectByExample with line d) below. If I commented out line d) then the query works ok. a) LocationExample example = new LocationExample(); b) LocationExample..Criteria criteria = example.createCriteria(); c) criteria.andLocationIdEqualTo(1); d) criteria.andLocationTypeEqualTo(LocationType.GENERAL); e) List<Location> result = locationDao.selectByExample(example); 5) The stack trace are shown below. Using the debugger, all the data looks to be valid, especially 'oredCriteria[0].criteriaWithSingleValue[1].value' Caused by: com.ibatis.common.jdbc.exception.NestedSQLException: --- The error occurred while applying a parameter map. --- Check the LOCATION.abatorgenerated_selectByExample-InlineParameterMap. --- Check the parameter mapping for the 'oredCriteria[0].criteriaWithSingleValue[1].value' property. --- Cause: java.lang.NullPointerException Caused by: java.lang.NullPointerException at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:188) at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForList(GeneralStatement.java:123) at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:614) at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:588) at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:118) at org.springframework.orm.ibatis.SqlMapClientTemplate$3.doInSqlMapClient(SqlMapClientTemplate.java:298) at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:209) ... 23 more Caused by: java.lang.NullPointerException at com.ibatis.sqlmap.engine.type.UnknownTypeHandler.setParameter(UnknownTypeHandler.java:70) at com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParameter(BasicParameterMap.java:165) at com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParameters(BasicParameterMap.java:125) at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:180) at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteQuery(GeneralStatement.java:205) at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:173)