ibatis - Nested ResultMaps with ambiguous database columns -
ibatis - Nested ResultMaps with ambiguous database columns -
i have couple of nested resultmaps in ibatis have same database column names. causing ambiguity , resulting in wrong result beingness retrieved different database tables.
for e.g., `
<sql namespace="shipment"> <resultmap id="consignment" class="com.model.consignment"> <result property="consignmentid" column="consignment_cd" /> <result property="shipmentcd" column="shipment_cd" /> <result property="shipmentunit" column="shipment_unit" /> <result property="location" resultmap="shipment.size" /> </resultmap> <resultmap id="size" class="com.model.size"> <result property="consignmentid" column="consignment_cd" /> <result property="shipmentcd" column="shipment_cd" /> <result property="shipmentunit" column="shipment_unit" /> </resultmap> </sql>
`
now when write select query joining size & consignment tables, same values shipment code , shipment unit returned, whereas there different values these 2 columns in database. please note need both shipment code , unit both size , consignment levels pulled in single query.
could help me solve problem?
the solution found issue prefixing column names table name or short name. writing queries right?
your select like
select consignment.shipment_cd consignment_shipment_cd, size.shipment_cd size_shipment_cd consignment bring together size on whatever
and yes pretty heavy if want lot of stuff in same query
ibatis
Comments
Post a Comment