There haven't been many changes since the 2.2.0 release - and none in this area of the code. Probably not the issue.
My question is this - why is UnknownTypeHandler being called at all? iBATIS only calls this when it does not find a registered type handler. My guess is that you're not declaring the type handler properly.
Jeff Butler
On 10/17/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]
> wrote:
I'm using 2.2.0 that I built from source on 9/22/06. (I guess that's old by now)
From: Tom Duffey <[EMAIL PROTECTED]> [mailto: Tom Duffey < [EMAIL PROTECTED]>]
Sent: Tuesday, October 17, 2006 8:40 AM
To: [email protected]
Subject: Re: Problem w/enum and TypeHandlerCallback
On Oct 17, 2006, at 10:34 AM, [EMAIL PROTECTED] wrote:
My enums are enclosed within another class, not external. As an example:Are you using iBATIS 2.2 or below? As far as I can tell the problem was introduced in 2.2.
Tompublic class DocumentStore extends DomainObject {
public static enum MsgType { REQUEST, CONFIRM }
The TypeHandler declaration looks like the following:<typeHandler javaType= "com.sybase.cosmos.domain.DocumentStore$MsgType" callback="com.sybase.cosmos.dao.impl.ibatis.extentions.DocMsgTypeTypeHandlerCallback " />
From: Tom Duffey <[EMAIL PROTECTED]> [ mailto:Tom Duffey <[EMAIL PROTECTED]>]
Sent: Tuesday, October 17, 2006 6:12 AM
To: [email protected]
Subject: Re: Problem w/enum and TypeHandlerCallback
On Oct 17, 2006, at 1:46 AM, [EMAIL PROTECTED] wrote:
I'm using Enums without difficulty. I've implemented a TypeHandlerCallback to accommodate the set and get in the following manner:Are your enums enclosed within another class or external? My enums are enclosed within classes and iBATIS is looking for a type handler for the enclosing class on insert/update instead of the enum. Using externally declared enums w/the same type handler works fine.
Tom
Hi All,
From: Tom Duffey <[EMAIL PROTECTED]> [ mailto:Tom Duffey <[EMAIL PROTECTED]>]
Sent: Monday, October 16, 2006 4:48 PM
To: [email protected]
Subject: Problem w/enum and TypeHandlerCallback
I'm having a problem with Java 5 Enums and iBATIS
TypeHandlerCallbacks. I've read the wiki article and it doesn't help
with my particular issue. Retrieving objects is working fine but
inserting/updating them is throwing this NPE:
java.lang.NullPointerException
at com.ibatis.sqlmap.engine.type.UnknownTypeHandler.setParameter
(UnknownTypeHandler.java:72)
at
com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParamete
r(BasicParameterMap.java:165)
at
com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParamete
rs(BasicParameterMap.java:125)
at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeUpdate
(SqlExecutor.java:76)
at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteUp
date(GeneralStatement.java:200)
at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdat
e(GeneralStatement.java:78)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert
(SqlMapExecutorDelegate.java:446)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert
(SqlMapSessionImpl.java :82)
at org.springframework.orm.ibatis.SqlMapClientTemplate
$9.doInSqlMapClient(SqlMapClientTemplate.java:358)
at org.springframework.orm.ibatis.SqlMapClientTemplate.execute
(SqlMapClientTemplate.java:188)
at org.springframework.orm.ibatis.SqlMapClientTemplate.insert
(SqlMapClientTemplate.java:356)
...
Here's my basic setup:
public interface Tenant {
public enum Type { FOO, BAR }
public Type getType();
public void setType(Type type);
...
}
public class TenantImpl implements Tenant {
private Type type;
public Type getType() { return type; }
public void setType(Type type) { this.type = type; }
...
}
My type handler for Tenant$Type looks a lot like the examples in the
wiki article. The types are mapped in my SqlMapConfig:
callback="com.utilivisor.dao.ibatis.TenantTypeEnumTypeHandler "/>
I'm messing around with UnknownTypeHandler.setParameter() and am very
confused. I checked the incoming value of parameter.getClass() and
it is correct, i.e., foo.bar.Tenant$Type. usingJavaPre5 is set
(Which is confusing by itself because I am using Java5) so
getBaseClass() is called and the new searchClass is foo.bar.Tenant.
I do not have or want a type handler for foo.bar.Tenant. Can anyone
help?
Tom
