Hi All,

I'm looking at revision 464707 (Latest available on trunk this afternoon) of com.ibatis.sqlmap.engine.type.UnknownTypeHandler and am puzzled by its setParameter() method:

public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType)
      throws SQLException {
    Class searchClass = parameter.getClass();
    if ( usingJavaPre5 )  {
        try  {
            searchClass = getBaseClass(searchClass);
        }
        catch ( Exception ex ) {
            searchClass = null;
        }
    }
    if ( searchClass == null )  {
        searchClass = parameter.getClass();
    }
TypeHandler handler = factory.getTypeHandler(searchClass, jdbcType);
    handler.setParameter(ps, i, parameter, jdbcType);
  }

Why the call to getBaseClass() for JDK5? The comment above getBaseClass() is puzzling, too:

  /**
   * Get the base class of classParam, for top level classes
   * this returns null. For enums, inner and anonymous
   * classes it returns the enclosing class. The intent
   * is to use this for enum support in Java 5+.
   *
   * @param classParam class to get enclosing class of
   * @return Enclosing class
   * @throws NoSuchMethodException when run in pre Java 5.
   */
  private static Class getBaseClass(Class classParam) { ... }

If I specify a type handler for an inner class or enum, why would I ever want iBATIS to look for a type handler for that inner class/ enum's enclosing class? I am experiencing a problem right now where I specify a type handler for foo.bar.Person$Type and when I do an insert/update the aforementioned code results in iBATIS searching for a type handler for foo.bar.Person and generates an NPE at:

    handler.setParameter(ps, i, parameter, jdbcType);

because no such type handler exists.  What am I missing?

I am happy to provide code, stack traces, etc. if you agree that this is a problem.

Tom

Reply via email to