|
My enums are enclosed within another class, not external. As an
example:
public 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"
/>
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,
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
|
- RE: Problem w/enum and TypeHandlerCallback Christopher . Mathrusse
-