- If the entity is a direct reference to another specific object parameter field, the original way directly on the line
<resultMap id="baseMap" type="com.ei.medical.modules.model.EduEducationKnowledge">
<result column="visitNumber" property="visitNumber"/>
<result column="patientName" property="patientName"/>
<result column="sendTime" property="sendTime"/>
<result column="wardCode" property="wardCode"/>
<result column="wardName" property="wardName"/>
<result column="categoryCode" property="categoryCode"/>
<result column="title" property="title"/>
<result column="content" property="content"/>
<result column="cover" property="cover"/>
</resultMap>
<select id="getAllBy" resultMap="baseMap">
SELECT
eer.visit_number as visitNumber,
eer.patient_name as patientName,
eer.send_time as sendTime,
eek.id as id,
eek.ward_code as wardCode,
eek.ward_name as wardName,
eek.category_code as categoryCode,
eek.title as title,
eek.content as content,
eek.cover as cover
FROM
edu_education_record AS eer,
edu_education_knowledge AS eek
WHERE
eer.education_knowledge_id=eek.id
</select>
- If the other entity is an entity object references, you should use the tag collection
<resultMap id="baseMap" type="com.ei.medical.modules.model.EduEducationKnowledge">
<result column="wardCode" property="wardCode"/>
<result column="wardName" property="wardName"/>
<result column="categoryCode" property="categoryCode"/>
<result column="title" property="title"/>
<result column="content" property="content"/>
<result column="cover" property="cover"/>
<collection property="eduEducationRecord" ofType="com.ei.medical.modules.model.EduEducationRecord">
<result column="visitNumber" property="visitNumber"/>
<result column="patientName" property="patientName"/>
<result column="sendTime" property="sendTime"/>
</collection>
</resultMap>
<select id="getAllBy" resultMap="baseMap">
SELECT
eer.visit_number as visitNumber,
eer.patient_name as patientName,
eer.send_time as sendTime,
eek.id as id,
eek.ward_code as wardCode,
eek.ward_name as wardName,
eek.category_code as categoryCode,
eek.title as title,
eek.content as content,
eek.cover as cover
FROM
edu_education_record AS eer,
edu_education_knowledge AS eek
WHERE
eer.education_knowledge_id=eek.id
</select>
- If the entity is referenced in the collection of other objects, you can use the association tag to write
<resultMap id="baseMap" type="com.ei.medical.modules.model.EduEducationKnowledge">
<result column="wardCode" property="wardCode"/>
<result column="wardName" property="wardName"/>
<result column="categoryCode" property="categoryCode"/>
<result column="title" property="title"/>
<result column="content" property="content"/>
<result column="cover" property="cover"/>
<association property="eduEducationRecordList" resultMap="base2Map"/>
</resultMap>
<resultMap id="base2Map" type="com.ei.medical.modules.model.EduEducationRecord">
<result column="visitNumber" property="visitNumber"/>
<result column="patientName" property="patientName"/>
<result column="sendTime" property="sendTime"/>
</resultMap>
<select id="getAllBy" resultMap="baseMap">
SELECT
eer.visit_number as visitNumber,
eer.patient_name as patientName,
eer.send_time as sendTime,
eek.id as id,
eek.ward_code as wardCode,
eek.ward_name as wardName,
eek.category_code as categoryCode,
eek.title as title,
eek.content as content,
eek.cover as cover
FROM
edu_education_record AS eer,
edu_education_knowledge AS eek
WHERE
eer.education_knowledge_id=eek.id
</select>
tips:
Use resultMap, it should directly behind as the field name, the name that is my fate
if not used as words, direct use of the database original name
ResultMap meaning of each tag