Index: java/mapper/mapper2/src/com/ibatis/sqlmap/engine/type/TypeHandlerFactory.java =================================================================== --- java/mapper/mapper2/src/com/ibatis/sqlmap/engine/type/TypeHandlerFactory.java (revision 659626) +++ java/mapper/mapper2/src/com/ibatis/sqlmap/engine/type/TypeHandlerFactory.java (working copy) @@ -25,6 +25,21 @@ */ public class TypeHandlerFactory { + /** Primitive type name -> class map. */ + private static final Map WRAPPER_TO_PRIMITIVE_MAP = new HashMap(); + + /** Setup the primitives map. */ + static { + WRAPPER_TO_PRIMITIVE_MAP.put(Boolean.class, Boolean.TYPE); + WRAPPER_TO_PRIMITIVE_MAP.put(Byte.class, Byte.TYPE); + WRAPPER_TO_PRIMITIVE_MAP.put(Char.class, Character.TYPE); + WRAPPER_TO_PRIMITIVE_MAP.put(Short.class, Short.TYPE); + WRAPPER_TO_PRIMITIVE_MAP.put(Integer.class, Integer.TYPE); + WRAPPER_TO_PRIMITIVE_MAP.put(Long.class, Long.TYPE); + WRAPPER_TO_PRIMITIVE_MAP.put(Float.class, Float.TYPE); + WRAPPER_TO_PRIMITIVE_MAP.put(Double.class, Double.TYPE); + } + private final Map typeHandlerMap = new HashMap(); private final TypeHandler unknownTypeHandler = new UnknownTypeHandler(this); private final HashMap typeAliases = new HashMap(); @@ -36,36 +51,14 @@ * Default constructor */ public TypeHandlerFactory() { - TypeHandler handler; + register(Boolean.class, new BooleanTypeHandler()); + register(Byte.class, new ByteTypeHandler()); + register(Short.class, new ShortTypeHandler()); + register(Integer.class, new IntegerTypeHandler()); + register(Long.class, new LongTypeHandler()); + register(Float.class, new FloatTypeHandler()); + register(Double.class, new DoubleTypeHandler()); - handler = new BooleanTypeHandler(); - register(Boolean.class, handler); - register(boolean.class, handler); - - handler = new ByteTypeHandler(); - register(Byte.class, handler); - register(byte.class, handler); - - handler = new ShortTypeHandler(); - register(Short.class, handler); - register(short.class, handler); - - handler = new IntegerTypeHandler(); - register(Integer.class, handler); - register(int.class, handler); - - handler = new LongTypeHandler(); - register(Long.class, handler); - register(long.class, handler); - - handler = new FloatTypeHandler(); - register(Float.class, handler); - register(float.class, handler); - - handler = new DoubleTypeHandler(); - register(Double.class, handler); - register(double.class, handler); - register(String.class, new StringTypeHandler()); register(String.class, "CLOB", new CustomTypeHandler(new ClobTypeHandlerCallback())); register(String.class, "LONGVARCHAR", new CustomTypeHandler(new ClobTypeHandlerCallback())); @@ -191,13 +184,17 @@ typeHandlerMap.put(type, map); } map.put(jdbcType, handler); + // check if this type has a matching primitive. If so register the same handler under the primitive class + if (WRAPPER_TO_PRIMITIVE_MAP.containsKey(type)){ + register((Class) WRAPPER_TO_PRIMITIVE_MAP.get(type), jdbcType, handler); + } } /** * Lookup an aliased class and return it's REAL name - * + * * @param string - the alias - * + * * @return - the REAL name */ public String resolveAlias(String string) {