On Sun, Feb 21, 2010 at 10:50 PM, Clinton Begin <[email protected]>wrote:
> Oh... also put an <id> element on the parent (likee parentValueID?).
>
>
Ok that's even more weird now. When I changed:
<result column="parentValueID" property="parentValueID" jdbcType="INTEGER"
/>
to
<id property="parentValueID" column="parentValueID" jdbcType="INTEGER"/>
I now end up with 6 of the rows mapped to objects (instead of 7 without it
.. and remember there should be 13 objects total.)
> 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.
>
I'm curious what part I'm automapping? I thought I was doing it just as I
saw in your blog example in the PDF?
I even changed it a bit to be more like your example (not that in my case
I'd think I would need to get the value of attributeValueID more than once.)
SELECT
aga.parentValueID,
aga.objectType,
aga.defaultValueFlag,
aga.attributeValueID as parent_avID,
av.attributeValueID,
av.value,
av.attributeValueDesc,
av.requiredFlag
FROM
<resultMap id="ProdAttrGroupAttrValueResultWithAttributeValue"
type="ProdAttrGroupAttrValue">
<id property="parentValueID" column="parentValueID"
jdbcType="INTEGER"/>
<result column="defaultValueFlag" property="defaultValueFlag"
jdbcType="CHAR" />
<result column="objectType" property="objectType" jdbcType="VARCHAR"
/>
<!--<result column="parentValueID" property="parentValueID"
jdbcType="INTEGER" /> -->
<association property="attributeValue" column="parent_avID"
javaType="AttributeValue">
<id property="attributeValueID" column="attributeValueID"
jdbcType="INTEGER"/>
<result column="value" property="value" jdbcType="VARCHAR"/>
<result column="attributeValueDesc"
property="attributeValueDesc" jdbcType="VARCHAR" />
<result column="requiredFlag" property="requiredFlag"
jdbcType="CHAR" />
</association>
</resultMap>
To Guy's point, not sure if the object's I'm mapping to matter? but if so:
public class ProdAttrGroupAttrValue extends BaseModel {
private String defaultValueFlag;
private String objectType;
private Integer parentValueID;
private Integer productID;
private Integer sequenceNumber;
private AttributeValue attributeValue; //the association object I'm
trying to populate
private AttributeGroup attributeGroup; //not used here
//...set/gets
public class AttributeValue extends BaseModel {
private List<AttributeValue> attributeValueDependencies; //not used here
in this query
private Integer attributeValueID;
private String value;
private String attributeValueDesc;
private String requiredFlag;
//... set/gets
I'm sure this is going to come down to a typo or something. I can just feel
it, because it seems like I'm doing things correctly?