[ 
http://issues.apache.org/jira/browse/IBATIS-224?page=comments#action_12367847 ] 

Sven Boden commented on IBATIS-224:
-----------------------------------

I reduced the testcase so it uses HSQL and can be run from the test directory 
(if you unzip the zip file in java\mapper\mapper2\test\com\ibatis\sqlmap), in 
case someone else also wants to have a go at it.

I found out why it's going wrong but don't have a solution. The problem is in 
the generics (which iBATIS doesn't officially support yet). Using dynamic 
elements the resolution of types is handled by the UnknownTypeHandler which 
tries to resolve the type via a TypeHandlerFactory.
The problem is that with generics the class name changes... you have an iBATIS 
type handler  for com.ibatis.sqlmap.java15.TestObject$AProperty while in 
reality the type is com.ibatis.sqlmap.java15.TestObject$AProperty$1, 
com.ibatis.sqlmap.java15.TestObject$AProperty$2, ... This is easy to proof: I 
added typehandlers for these type in the SqlMap.xml file and if you uncomment 
them all examples will work.

So it's a combination of typehandlers, generics and dynamic functionality that 
causes the problem.

> isNotNull node causes typehandler mappings in statement to fail
> ---------------------------------------------------------------
>
>          Key: IBATIS-224
>          URL: http://issues.apache.org/jira/browse/IBATIS-224
>      Project: iBatis for Java
>         Type: Bug
>   Components: SQL Maps
>     Versions: 2.1.6
>  Environment: linux/java 1.5
>     Reporter: Reuben Firmin
>     Priority: Critical
>  Attachments: ibatis-224_sven.zip, ibatis224.tar.gz
>
> Here's my insert statement.
>     <insert id="createDeployment" parameterClass="deployment">
>         INSERT INTO Deployment (
>             environmentId, deploymentTypeId, deploymentStatusId, 
> deploymentTime
>                 <isNotNull 
> property="threadCountOverride">,threadCountOverride</isNotNull>
>         ) VALUES (
>             #environmentId#, #deploymentTypeId#, #deploymentStatusId#, 
> #deploymentTime#
>                 <isNotNull 
> property="threadCountOverride">,#threadCountOverride#</isNotNull>
>         )
>         <selectKey resultClass="int" keyProperty="deploymentId">
>             SELECT @@IDENTITY as value
>         </selectKey>
>     </insert>
> deploymentTypeId and deploymentStatusId are enums in the bean, mapped to 
> values using custom type handlers. Without the isNotNull structure around 
> threadCountOverride (which *is* nullable), the statement works. With the 
> isNotNull, deploymentStatusId and deploymentTypeId are mapped to 
> UnknownTypeHandler, and the insert fails to map the parameters from the bean.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to