<select id="getModelById" resultMap="modelTypeMap">
SELECT id as id,
model_id AS modelId,
model_type AS modelType,
created_by AS createdBy,
model_name AS modelName,
model_def AS modelDef,
start_date AS startDate,
end_date AS endDate,
FROM
<include refid="user_defined_4a_model"/>
WHERE model_id=#{modelId}
</select>
<resultMap id="modelTypeMap" type="com.javartisan.BaseModel">
<discriminator javaType="java.lang.Integer" column="modelType">
<case value="1" resultType="com.javartisan.Model1"/>
<case value="2" resultType="com.javartisan.Model2"/>
</discriminator>
</resultMap>