ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guy Rouillier <guyr-...@burntmail.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:31:42 GMT
I see what is happening (from the results - I have not read the code and 
I'm not one of the product's authors.)  It appears to be generating an 
object only on change of value for parentValueID, though you haven't 
identified that column as an ID column.  There are two objects with 
value 15282 because of the intervening row with 9043.  Notice that your 
second 15282 object has the contents from row 4, not from row 2.  For 
all other duplicates, only the first of the duplicate rows results in an 
object.

And when I say duplicate rows, I don't mean the entire row is 
duplicated, only the parentValueID.  Are you sure there is not something 
in your target class ProdAttrGroupAttrValue that is causing this behavior?

On 2/21/2010 8:51 PM, Rick R wrote:
>
>
> On Sun, Feb 21, 2010 at 8:01 PM, Clinton Begin <clinton.begin@gmail.com
> <mailto:clinton.begin@gmail.com>> wrote:
>
>     It rolls up by <id> elements, or if none exist, it rolls up by all
>     columns (which is why specifying an id is important).
>
>
> I did provide an id which adds to my confusion.
>
> <association property="attributeValue" column="attributeValueID"
> javaType="AttributeValue">
> <id property="attributeValueID" column="attributeValueID"/>
>
> The select is:
>
> SELECT
>           agaparentValueID,
>           aga.objectType,
>           aga.defaultValueFlag,
>           aga.attributeValueID,
>           av.value,
>           av.attributeValueDesc,
>           av.requiredFlag
>      FROM
>
>
>
>     Clinton
>
>
>     On Sun, Feb 21, 2010 at 5:55 PM, Rick R <rickcr@gmail.com
>     <mailto: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.nielsendataselector.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>
>         ]
>
>
>
>
>
> --
> Rick R


-- 
Guy Rouillier

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Mime
View raw message