-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
enhancementImprove a feature or add a new featureImprove a feature or add a new feature
Milestone
Description
Hi !
I'm using mybatis 3.3.0.
The following mapper generates a NPE when used, because no resultType attribute is set on the <case> tags. The aim is to fill an interface/abstract/parent object with the right implementation :
<resultMap type="Owner" id="ownerMap">
<id property="id" column="id" />
<result property="name" column="name" />
<discriminator javaType="string" column="vehicle_type">
<case value="car">
<association property="vehicle" column="vehicle_id" select="CarMapper.get" />
</case>
<case value="truck">
<association property="vehicle" column="vehicle_id" select="TruckMapper.get" />
</case>
</discriminator>
</resultMap>To make it working, the attribute resultType="Owner" must be set on the <case> tags, although it is not marked as required :
<resultMap type="Owner" id="ownerMap">
<id property="id" column="id" />
<result property="name" column="name" />
<discriminator javaType="string" column="vehicle_type">
<case value="car" resultType="Owner">
<association property="vehicle" column="vehicle_id" select="CarMapper.get" />
</case>
<case value="truck" resultType="Owner">
<association property="vehicle" column="vehicle_id" select="TruckMapper.get" />
</case>
</discriminator>
</resultMap>It would be nice if, when the resultType attribute is not set, it automatically references the type set on the resultMap.
Julan76 and mzdz
Metadata
Metadata
Assignees
Labels
enhancementImprove a feature or add a new featureImprove a feature or add a new feature