Not exactly.
In MyBatis, it can be achieved by defining <sql />
with variables.
<sql id="patientInfoColumns">
${alias}emrId AS ${prefix}emrId,
${alias}version AS ${prefix}version,
...
</sql>
For a query that does not require alias/prefix (i.e. patientInfo
is the root table), you just include the fragment as-is.
<select id="getPatientInfo" resultMap="PatientInfoMapper">
select
<include refid="patientInfoColumns" />
from patientInfo
where emrId = #{emrId}
</select>
And in a query with JOINs, include the fragment with ‘alias’ and ‘prefix’ specified.
<select id="getPatientInfo" resultMap="PatientInfoMapper">
select
<include refid="patientColumns" />
,
<include refid="patientInfoColumns">
<property name="alias" value="PI." />
<property name="prefix" value="pi_" />
</include>
from patient
join patientInfo PI on ...
</select>
So, with your example, columnPrefix
should be specified in the <association />
in PatientMapper
.
If you have any difficulty, share an executable test case or example project on GitHub and I’ll help you make it work. :)
Regards,
Iwao
--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.