ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clinton Begin <clinton.be...@gmail.com>
Subject Re: why is ibatis rolling up for an association, not sure why this isn't flat, or what its rolling up on?
Date Mon, 22 Feb 2010 03:50:38 GMT
Oh... also put an <id> element on the parent (likee parentValueID?).

Also, be careful with automapping and nested results.  In Beta 9 I added
configuration to disable automapping for nested results, only because it was
confusing where the results would end up.  But that doesn't look like a
problem here, as you don't have conflicting property names.

Clinton

On Sun, Feb 21, 2010 at 5:55 PM, Rick R <rickcr@gmail.com> wrote:

> I'm now starting to get into using ibatis3 more and I'm curious about why a
> 'roll up' is happening (based on a column I didn't mention as a rollup
> column) when I use an association. I'm sure it's something stupid I'm
> missing but I don't see it.
>
> For example this flat structure works just fine, and its what I've used in
> ibatis2 for a simple flat structure:
>
> <resultMap id="ProdAttrGroupAttrValueResultWithAttributeValue"
> type="ProdAttrGroupAttrValue">
>         <result column="defaultValueFlag" property="defaultValueFlag"
> jdbcType="CHAR" />
>         <result column="objectType" property="objectType"
> jdbcType="VARCHAR" />
>         <result column="parentValueID" property="parentValueID"
> jdbcType="INTEGER" />
>         <!-- the ProAttrGroupAttrValue has an attributeValue object
> property: -->
>         <result property="attributeValue.attributeValueID"
> column="attributeValueID"/>
>          <result column="value" property="attributeValue.value"
> jdbcType="VARCHAR"/>
>          <result column="attributeValueDesc"
> property="attributeValue.attributeValueDesc" jdbcType="VARCHAR" />
>          <result column="requiredFlag"
> property="attributeValue.requiredFlag" jdbcType="CHAR" />
>  </resultMap>
>
>  But I thought I should follow ibatis3 conventions and use an association
> to make it more clear:
>
> <resultMap id="ProdAttrGroupAttrValueResultWithAttributeValue"
> type="ProdAttrGroupAttrValue">
>         <result column="defaultValueFlag" property="defaultValueFlag"
> jdbcType="CHAR" />
>         <result column="objectType" property="objectType"
> jdbcType="VARCHAR" />
>         <result column="parentValueID" property="parentValueID"
> jdbcType="INTEGER" />
>         <!-- using an association instead -->
>         <association property="attributeValue" column="attributeValueID"
> javaType="AttributeValue">
>             <id property="attributeValueID" column="attributeValueID"/>
>             <result column="value" property="value" jdbcType="VARCHAR"/>
>             <result column="attributeValueDesc"
> property="attributeValueDesc" jdbcType="VARCHAR" />
>             <result column="requiredFlag" property="requiredFlag"
> jdbcType="CHAR" />
>         </association>
> </resultMap>
>
> However, when I use the latter association approach I end up getting rows
> completely thrown out, but I'm not sure why and/or what logic its using.
> The query returns 13 rows, but I only end up with 7 objects in the latter
> association approach..
>
>
> DEBUG [main] java.sql.PreparedStatement debug- ==> Parameters: 2(Integer),
> 12(Integer), 100(Integer)
> DEBUG [main] java.sql.ResultSet debug- <==    Columns: parentValueID,
> objectType, defaultValueFlag, attributeValueID, value, attributeValueDesc,
> requiredFlag
> DEBUG [main] java.sql.ResultSet debug- <==        Row: 15282, Checkbox, Y,
> 9042, AA, US AA %, N
> DEBUG [main] java.sql.ResultSet debug- <==        Row: 15282, Checkbox, N,
> 9043, GAA, US GAA %, N
> DEBUG [main] java.sql.ResultSet debug- <==        Row: 9043, Checkbox, N,
> 12059, nonOrderedGAATelecasts, Allow Non Ordered GAA, N
> DEBUG [main] java.sql.ResultSet debug- <==        Row: 15282, Checkbox, N,
> 12371, cvgAApercent, CVG AA %, N
> DEBUG [main] java.sql.ResultSet debug- <==        Row: 15282, Checkbox, N,
> 13260, cvgGAApercent, CVG GAA %, N
> DEBUG [main] java.sql.ResultSet debug- <==        Row: 12524, Checkbox, N,
> 9044, HUT/Share, US HUT/PUT and Share %, N
> DEBUG [main] java.sql.ResultSet debug- <==        Row: 12524, Checkbox, N,
> 9063, MAMI, Median Age / Median Income, N
> DEBUG [main] java.sql.ResultSet debug- <==        Row: 15298, Checkbox, N,
> 15299, indexP2, Index % P2+, N
> DEBUG [main] java.sql.ResultSet debug- <==        Row: 15298, Checkbox, N,
> 15304, CVG_Index_P18_plus, CVG Index % P18+, N
> DEBUG [main] java.sql.ResultSet debug- <==        Row: 12396, Checkbox, N,
> 12391, Commercial, National Commercial Statistics, N
> DEBUG [main] java.sql.ResultSet debug- <==        Row: 15284, Checkbox, N,
> 9064, RGL, Reach, Gain/Loss, N
> DEBUG [main] java.sql.ResultSet debug- <==        Row: 15284, Checkbox, N,
> 11135, vcrContribution, VCR Contribution, N
> DEBUG [main] java.sql.ResultSet debug- <==        Row: 15284, Checkbox, N,
> 11134, avgMinutesViewed, Average Minutes Viewed, N
>
>
> 13 rows but only 7 Objects using association:
>
> DEBUG [main] com.nielsen.dataselector.media.service.TestAttributeGroup
> testGetStatistics- TestAttributeGroup ProdAttrGroupAttrValue:
> com.nielsen.dataselector.media.service.model.ProdAttrGroupAttrValue@40e99ce5
> [
>   defaultValueFlag=Y
>   objectType=Checkbox
>   parentValueID=15282
>   productID=<null>
>   sequenceNumber=<null>
>
> attributeValue=com.nielsen.dataselector.media.service.model.AttributeValue@342f356f
> [
>   attributeValueDependencies=<null>
>   attributeValueID=9042
>   value=AA
>   attributeValueDesc=US AA %
>   requiredFlag=N
> ]
>   attributeGroup=<null>
> ]
> DEBUG [main] com.nielsen.dataselector.media.service.TestAttributeGroup
> testGetStatistics- TestAttributeGroup ProdAttrGroupAttrValue:
> com.nielsen.dataselector.media.service.model.ProdAttrGroupAttrValue@75d252d
> [
>   defaultValueFlag=N
>   objectType=Checkbox
>   parentValueID=15282
>   productID=<null>
>   sequenceNumber=<null>
>
> attributeValue=com.nielsen.dataselector.media.service.model.AttributeValue@7433b121
> [
>   attributeValueDependencies=<null>
>   attributeValueID=13260
>   value=cvgGAApercent
>   attributeValueDesc=CVG GAA %
>   requiredFlag=N
> ]
>   attributeGroup=<null>
> ]
> DEBUG [main] com.nielsen.dataselector.media.service.TestAttributeGroup
> testGetStatistics- TestAttributeGroup ProdAttrGroupAttrValue:
> com.nielsen.dataselector.media.service.model.ProdAttrGroupAttrValue@6db22920
> [
>   defaultValueFlag=N
>   objectType=Checkbox
>   parentValueID=9043
>   productID=<null>
>   sequenceNumber=<null>
>
> attributeValue=com.nielsen.dataselector.media.service.model.AttributeValue@4baa2c23
> [
>   attributeValueDependencies=<null>
>   attributeValueID=12059
>   value=nonOrderedGAATelecasts
>   attributeValueDesc=Allow Non Ordered GAA
>   requiredFlag=N
> ]
>   attributeGroup=<null>
> ]
> DEBUG [main] com.nielsen.dataselector.media.service.TestAttributeGroup
> testGetStatistics- TestAttributeGroup ProdAttrGroupAttrValue:
> com.nielsen.dataselector.media.service.model.ProdAttrGroupAttrValue@5f18223d
> [
>   defaultValueFlag=N
>   objectType=Checkbox
>   parentValueID=12524
>   productID=<null>
>   sequenceNumber=<null>
>
> attributeValue=com.nielsen.dataselector.media.service.model.AttributeValue@29700391
> [
>   attributeValueDependencies=<null>
>   attributeValueID=9063
>   value=MAMI
>   attributeValueDesc=Median Age / Median Income
>   requiredFlag=N
> ]
>   attributeGroup=<null>
> ]
> DEBUG [main] com.nielsen.dataselector.media.service.TestAttributeGroup
> testGetStatistics- TestAttributeGroup ProdAttrGroupAttrValue:
> com.nielsen.dataselector.media.service.model.ProdAttrGroupAttrValue@78fa39d7
> [
>   defaultValueFlag=N
>   objectType=Checkbox
>   parentValueID=15298
>   productID=<null>
>   sequenceNumber=<null>
>
> attributeValue=com.nielsen.dataselector.media.service.model.AttributeValue@73eb904d
> [
>   attributeValueDependencies=<null>
>   attributeValueID=15304
>   value=CVG_Index_P18_plus
>   attributeValueDesc=CVG Index % P18+
>   requiredFlag=N
> ]
>   attributeGroup=<null>
> ]
> DEBUG [main] com.nielsen.dataselector.media.service.TestAttributeGroup
> testGetStatistics- TestAttributeGroup ProdAttrGroupAttrValue:
> com.nielsen.dataselector.media.service.model.ProdAttrGroupAttrValue@6e4eeaaf
> [
>   defaultValueFlag=N
>   objectType=Checkbox
>   parentValueID=12396
>   productID=<null>
>   sequenceNumber=<null>
>
> attributeValue=com.nielsen.dataselector.media.service.model.AttributeValue@7f11bfbc
> [
>   attributeValueDependencies=<null>
>   attributeValueID=12391
>   value=Commercial
>   attributeValueDesc=National Commercial Statistics
>   requiredFlag=N
> ]
>   attributeGroup=<null>
> ]
> DEBUG [main] com.nielsen.dataselector.media.service.TestAttributeGroup
> testGetStatistics- TestAttributeGroup ProdAttrGroupAttrValue:
> com.nielsen.dataselector.media.service.model.ProdAttrGroupAttrValue@664310d0
> [
>   defaultValueFlag=N
>   objectType=Checkbox
>   parentValueID=15284
>   productID=<null>
>   sequenceNumber=<null>
>
> attributeValue=com.nielsen.dataselector.media.service.model.AttributeValue@3d04fc23
> [
>   attributeValueDependencies=<null>
>   attributeValueID=11134
>   value=avgMinutesViewed
>   attributeValueDesc=Average Minutes Viewed
>   requiredFlag=N
> ]
>   attributeGroup=<null>
> ]
>
>

Mime
View raw message