ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher.Mathru...@sybase.com
Subject RE: Problem w/enum and TypeHandlerCallback
Date Tue, 17 Oct 2006 15:34:54 GMT
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META boundary="Apple-Mail-5-247382394" alternative; multipart Content-Type:>
<META http-equiv=Content-Type content="text/html; charset=us-ascii" 
Content-Type: --Apple-Mail-5-247382394 html; text quoted-printable 
Content-Transfer-Encoding:>
<META content="MSHTML 6.00.2900.2963" name=GENERATOR></HEAD>
<BODY 
style="WORD-WRAP: break-word; khtml-nbsp-mode: space; khtml-line-break: after-white-space">
<DIV dir=ltr align=left><SPAN class=157043215-17102006><FONT color=#0000ff

size=2>My enums are enclosed within another class, not external. As an 
example:</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=157043215-17102006><FONT color=#0000ff

size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=157043215-17102006><B><FONT color=#7f0055>
<P align=left><FONT size=2>public</FONT></B></FONT><FONT
size=2> <B><FONT 
color=#7f0055>class</B></FONT></FONT><FONT size=2> DocumentStore
<B><FONT 
color=#7f0055>extends</B></FONT></FONT><FONT size=2> DomainObject
{</FONT></P>
<P align=left><FONT size=2><B><FONT color=#7f0055><SPAN 
class=157043215-17102006>&nbsp;&nbsp;&nbsp; </SPAN>public</FONT></B>
<B><FONT 
color=#7f0055>static</B></FONT></FONT><FONT size=2> <B><FONT

color=#7f0055>enum</B></FONT></FONT><FONT size=2> MsgType { <I><FONT

color=#0000c0>REQUEST</I></FONT></FONT><FONT size=2>, <I><FONT

color=#0000c0>CONFIRM</I></FONT></FONT><FONT size=2> }</FONT></P>
<P align=left>&nbsp;</P></SPAN></DIV>
<DIV><FONT color=#0000ff size=2><SPAN class=157043215-17102006><FONT

color=#0000ff size=2>The TypeHandler declaration looks like the 
following:</FONT></SPAN></FONT></DIV>
<DIV><FONT size=2>
<P align=left></FONT><FONT color=#008080 size=2>&lt;</FONT><FONT
color=#3f7f7f 
size=2>typeHandler </FONT><FONT color=#7f007f size=2>javaType</FONT><FONT

size=2>=</FONT><FONT color=#2a00ff 
size=2>"com.sybase.cosmos.domain.DocumentStore$MsgType" </FONT><FONT 
color=#7f007f size=2>callback</FONT><FONT size=2>=</FONT><FONT color=#2a00ff

size=2>"com.sybase.cosmos.dao.impl.ibatis.extentions.DocMsgTypeTypeHandlerCallback" 
</FONT><FONT color=#008080 size=2>/&gt;</P></FONT><BR></DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> Tom Duffey &lt;tduffey@utilivisor.com&gt;

[mailto:Tom Duffey &lt;tduffey@utilivisor.com&gt;] <BR><B>Sent:</B>
Tuesday, 
October 17, 2006 6:12 AM<BR><B>To:</B> 
user-java@ibatis.apache.org<BR><B>Subject:</B> Re: Problem w/enum and 
TypeHandlerCallback<BR></FONT><BR></DIV>
<DIV></DIV><BR>
<DIV>
<DIV>On Oct 17, 2006, at 1:46 AM, <A 
href="mailto:Christopher.Mathrusse@sybase.com">Christopher.Mathrusse@sybase.com</A>

wrote:</DIV><BR class=Apple-interchange-newline>
<BLOCKQUOTE type="cite">
  <DIV dir=ltr align=left><FONT color=#0000ff size=2><SPAN 
  class=981004306-17102006>I'm using Enums without difficulty. I've implemented 
  a <FONT size=2>TypeHandlerCallback to accommodate the set and get in the 
  following manner:</FONT></SPAN></FONT></DIV></BLOCKQUOTE>
<DIV><BR class=khtml-block-placeholder></DIV>Are your enums enclosed within

another class or external?&nbsp; 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.&nbsp; Using externally declared enums w/the same type handler works 
fine.</DIV>
<DIV><BR class=khtml-block-placeholder></DIV>
<DIV>Tom</DIV>
<DIV><BR>
<BLOCKQUOTE type="cite">
  <DIV dir=ltr align=left><FONT color=#0000ff><SPAN 
  class=981004306-17102006></SPAN></FONT></DIV><BR>
  <DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
  <HR tabIndex=-1>
  <FONT face=Tahoma size=2><B>From:</B> Tom Duffey 
  &lt;tduffey@utilivisor.com&gt; [<A href="mailto:Tom">mailto:Tom</A>
Duffey 
  &lt;<A href="mailto:tduffey@utilivisor.com">tduffey@utilivisor.com</A>&gt;]

  <BR><B>Sent:</B> Monday, October 16, 2006 4:48 PM<BR><B>To:</B>
<A 
  href="mailto:user-java@ibatis.apache.org">user-java@ibatis.apache.org</A><BR><B>Subject:</B>

  Problem w/enum and TypeHandlerCallback<BR></FONT><BR></DIV>
  <DIV></DIV>Hi All, <BR><BR>I'm having a problem with Java 5 Enums
and iBATIS 
  <BR>TypeHandlerCallbacks. I've read the wiki article and it doesn't help 
  <BR>with my particular issue. Retrieving objects is working fine but 
  <BR>inserting/updating them is throwing this NPE: 
  <BR><BR>java.lang.NullPointerException <BR>at 
  com.ibatis.sqlmap.engine.type.UnknownTypeHandler.setParameter 
  <BR>(UnknownTypeHandler.java:72) <BR>at 
  <BR>com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParamete 
  <BR>r(BasicParameterMap.java:165) <BR>at 
  <BR>com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParamete 
  <BR>rs(BasicParameterMap.java:125) <BR>at 
  com.ibatis.sqlmap.engine.execution.SqlExecutor.executeUpdate 
  <BR>(SqlExecutor.java:76) <BR>at 
  <BR>com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteUp 
  <BR>date(GeneralStatement.java:200) <BR>at 
  <BR>com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdat 
  <BR>e(GeneralStatement.java:78) <BR>at 
  com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert 
  <BR>(SqlMapExecutorDelegate.java:446) <BR>at 
  com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert 
  <BR>(SqlMapSessionImpl.java:82) <BR>at 
  org.springframework.orm.ibatis.SqlMapClientTemplate 
  <BR>$9.doInSqlMapClient(SqlMapClientTemplate.java:358) <BR>at 
  org.springframework.orm.ibatis.SqlMapClientTemplate.execute 
  <BR>(SqlMapClientTemplate.java:188) <BR>at 
  org.springframework.orm.ibatis.SqlMapClientTemplate.insert 
  <BR>(SqlMapClientTemplate.java:356) <BR>... <BR><BR>Here's my basic
setup: 
  <BR><BR>public interface Tenant { <BR>public enum Type { FOO, BAR } <BR>public

  Type getType(); <BR>public void setType(Type type); <BR>... <BR>} <BR>public

  class TenantImpl implements Tenant { <BR>private Type type; <BR>public Type

  getType() { return type; } <BR>public void setType(Type type) { this.type = 
  type; } <BR>... <BR>} <BR><BR>My type handler for Tenant$Type looks
a lot like 
  the examples in the <BR>wiki article. The types are mapped in my SqlMapConfig: 
  <BR><BR><TYPEHANDLER><BR 
  javatype="foo.bar.Tenant$Type">callback="com.utilivisor.dao.ibatis.TenantTypeEnumTypeHandler"/&gt;

  <BR><BR>I'm messing around with UnknownTypeHandler.setParameter() and am very

  <BR>confused. I checked the incoming value of parameter.getClass() and <BR>it

  is correct, i.e., foo.bar.Tenant$Type. usingJavaPre5 is set <BR>(Which is 
  confusing by itself because I am using Java5) so <BR>getBaseClass() is called 
  and the new searchClass is foo.bar.Tenant. <BR>I do not have or want a type 
  handler for foo.bar.Tenant. Can anyone <BR>help? <BR><BR>Tom 
  <BR><BR></TYPEHANDLER></BLOCKQUOTE></DIV><BR></BODY></HTML>


Mime
View raw message