ibatis-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Bethell (JIRA)" <ibatis-...@incubator.apache.org>
Subject [jira] Commented: (IBATIS-352) Problems with Complex Properties + Sets & enums
Date Wed, 11 Oct 2006 11:43:21 GMT
    [ http://issues.apache.org/jira/browse/IBATIS-352?page=comments#action_12441427 ] 
            
Andrew Bethell commented on IBATIS-352:
---------------------------------------

I apologise for the poor description of my problem, hopefully I can give a clearer overview
of the problem this time.

I have a custom Type Handler that converts VARCHAR values ('ACT' , 'DEL', 'DIS'... ) to Enum
types (Active / Deleted / Disabled ..).  I followed the guide on the Ibatis Wiki that explains
how to use custom type handlers with java 5 enums - and everything worked fine initially,
but after I completed mapping my objects I started getting bulkbean exceptions.

I think I have isolated the problem to when custom typehandlers are applied to the items of
collection-complex properties, that are loaded with joins & resultMaps. 

When selecting data-  populating a single complex property which uses a custom type handler
works fine, when lazy loading and using joins + nested property mappings.  

However, when populating a complex property which is a collection (tried Set and List), and
the resultMap for that collection has a custom property - a bulkbeanexception is thrown (join-resultmap
with enum.txt).  - eg

(from my Article.xml)
<resultMap id="articleResult" class="org.andy.sandbox.domain.Article" groupBy="id">
...
<result property="resources" javaType="java.util.TreeSet" resultMap="Resource.resourceResult"/>
..
</resultMap>

In this example - resourceResult contains a property which uses a custom type handler.  This
happens when I declare a typehandler in my sqlMapConfig - ie

    <typeHandler javaType="org.andy.sandbox.domain.RecordStatus"
                 callback="org.andy.sandbox.dao.RecordTypeHandler"/>

and also when specifying a typehandler for a specific property - - in this case I am just
mapping to a value of type boolean

<result property="statuss" column="RESOURCE_REC_STATUS" typeHandler="org.andy.sandbox.dao.TestTypeHandler"/>-

If I remove the mappings for these properties, my selects work fine.

The same problem does not occur when lazy-loading a collection of items which have custom-type
properties - ie 

(from my Issue.xml)
<resultMap id="issueResult" class="org.andy.sandbox.domain.Issue" groupBy="id">
...
<result property="articles" column="ISSUE_ID" select="Article.getArticlesByIssue"/>
...
</resultMap>


> Problems with Complex Properties + Sets & enums
> -----------------------------------------------
>
>                 Key: IBATIS-352
>                 URL: http://issues.apache.org/jira/browse/IBATIS-352
>             Project: iBatis for Java
>          Issue Type: Bug
>          Components: SQL Maps
>    Affects Versions: 2.2.0
>         Environment: JDK 1.5, IBATIS SQL Maps 2.2.0.638, Spring 2.0
>            Reporter: Andrew Bethell
>         Attachments: join-resultmap with enum.txt, lazy-load with set.txt
>
>
> There doesnt seem to be support for lazy-loading complex properties of type 'java.util.Set',
only List collections -  (stack trace attached to this issue).
> I have to use Set collections at the moment, as when I upgraded from IBATIS SQLMaps 2.17
to 2.22, the 'groupBy' attribute for resultmaps did not seem to make data in (List) complex
properties distinct by ID, where as in version 2.17 this was the case.
> Strangely though, when loading complex properties with joins+resultMaps, Set properties
work correctly - except when items in the Set contain enum types (stack trace attached for
this too).

-- 
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

        

Mime
View raw message