ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tom Duffey <tduf...@utilivisor.com>
Subject Re: Problem w/enum and TypeHandlerCallback
Date Tue, 17 Oct 2006 15:40:11 GMT

On Oct 17, 2006, at 10:34 AM, Christopher.Mathrusse@sybase.com 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.

Tom

> 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.DocMsgTypeTypeH 
> andlerCallback" />
>
>
> From: Tom Duffey <tduffey@utilivisor.com> [mailto:Tom Duffey  
> <tduffey@utilivisor.com>]
> Sent: Tuesday, October 17, 2006 6:12 AM
> To: user-java@ibatis.apache.org
> Subject: Re: Problem w/enum and TypeHandlerCallback
>
>
> On Oct 17, 2006, at 1:46 AM, Christopher.Mathrusse@sybase.com 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
>
>>
>> From: Tom Duffey <tduffey@utilivisor.com> [mailto:Tom Duffey  
>> <tduffey@utilivisor.com>]
>> Sent: Monday, October 16, 2006 4:48 PM
>> To: user-java@ibatis.apache.org
>> Subject: Problem w/enum and TypeHandlerCallback
>>
>> 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.setParam 
>> ete
>> r(BasicParameterMap.java:165)
>> at
>> com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParam 
>> ete
>> rs(BasicParameterMap.java:125)
>> at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeUpdate
>> (SqlExecutor.java:76)
>> at
>> com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecut 
>> eUp
>> date(GeneralStatement.java:200)
>> at
>> com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUp 
>> dat
>> 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
>>
>


Mime
View raw message