[ https://issues.apache.org/jira/browse/IBATIS-568?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12689607#action_12689607 ]
Brian Sanders commented on IBATIS-568: -------------------------------------- This has been a point of confusion for my team, as well. If I have a typeHandler configured like: <typeHandler javaType="string" jdbcType="NVARCHAR" callback="foo.NVarcharTypeHandlerCallback"/> and a procedure such as: <procedure id="test"> {call MY_STORED_PROC(#in,javaType=string,jdbcType=NVARCHAR#)} </procedure> I would expect that the typeHandler used would be my custom typeHandler, based on the specified javaType and jdbcType tokens. However, my typeHandler is ignored. I must explicitly include the "handler" token in any inline parameter. InlineParameterMapParser.newParseMapping, around line 133, should be modified like: if (mapping.getTypeHandler() == null) { TypeHandler handler; if (parameterClass == null) { /* NEW */ if (mapping.getJavaTypeName() != null) { handler = typeHandlerFactory.getTypeHandler(Resources.classForName(mapping.getJavaTypeName(), mapping.getJdbcTypeName()); } else { handler = typeHandlerFactory.getUnkownTypeHandler(); } /* end NEW */ } else { handler = resolveTypeHandler(typeHandlerFactory, parameterClass, mapping.getPropertyName(), mapping.getJavaTypeName(), mapping.getJdbcTypeName()); } mapping.setTypeHandler(handler); } > Configured type handler not invoked on insert > --------------------------------------------- > > Key: IBATIS-568 > URL: https://issues.apache.org/jira/browse/IBATIS-568 > Project: iBatis for Java > Issue Type: Bug > Components: SQL Maps > Affects Versions: 2.3.3 > Environment: Windows XP Professional > Reporter: Richard R. Duffy > > Custom type handler which is configured in the SqlMapConfig is not being > invoked for an insert. The configured handler is as follows: > <typeHandler javaType="javax.xml.datatype.XMLGregorianCalendar" > jdbcType="TIMESTAMP" callback="com.aac.engine.dao.impl.TimeStampHandler"/> > The handler is called for queries (SELECT) and all TIMESTAMP data is > processed through the handler. However, the handler is not called on insert > statements. > Sample map file entry: > <insert id="insertAllowance" parameterClass="Allowance"> > INSERT INTO allowance > ( > jobid, > createdate, > allowancereminderid, > allowancetype, > allowancecategory, > allowanceworkarea, > allowanceduedate, > allowancedescription, > allowancematerialamounttype, > allowancematerialamount, > allowancematerialunits, > allowancematerialunittype, > allowancelaboramount, > allowancelaborvisible > <dynamic> > <isPropertyAvailable property="selection"> > ,selectiondescription, > selectionmaterialamount, > selectionlaboramount > </isPropertyAvailable> > </dynamic> > ) > VALUES > ( > #jobid#, > NOW(), > #reminderid#, > #type#, > #category#, > #workarea#, > #duedate#, > #description#, > #materialcalculation.type#, > #materialcalculation.typevalue#, > #materialunits#, > #materialunittype#, > #labortotal#, > #laborvisible# > <dynamic> > <isPropertyAvailable property="selection"> > ,#selection.description#, > #selection.materialamount#, > #selection.laboramount# > </isPropertyAvailable> > </dynamic> > ) > <selectKey type="post" resultClass="Integer"> > SELECT LAST_INSERT_ID() AS value > </selectKey> > </insert> > If I use an inline type handler for the date column (duedate) within the > insert map (such as > #private,handler=com.aac.engine.dao.impl.TimeStampHandler#) then it works > fine. > Sample inline specification: > #duedate,handler=com.aac.engine.dao.impl.TimeStampHandler#, > There was a similar issue reported for primitives (IBATIS-244) that was > resolved in 2.3.3. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.