1 Model类
public class Vo {
/**
* this is used for receive data partly from table user_question_section
*/
private Integer commonScore;
private Integer questionSectionDef;
/**
* @return the commonScore
*/
public Integer getCommonScore() {
return commonScore;
}
/**
* @param commonScore the commonScore to set
*/
public void setCommonScore(Integer commonScore) {
this.commonScore = commonScore;
}
/**
* @return the questionSectionDef
*/
public Integer getQuestionSectionDef() {
return questionSectionDef;
}
/**
* @param questionSectionDef the questionSectionDef to set
*/
public void setQuestionSectionDef(Integer questionSectionDef) {
this.questionSectionDef = questionSectionDef;
}
}
2.interface 接口类
List selectUserSectionsScore(Integer userId);
3.mapper文件中
1.首先定义一个resultmap,type指向你的model类
2.select语句中,要用resultMap指明你定义的resultmap
select usr.score,qs.def_section_id
from ui.user_question_section_xref usr
inner join ui.question_section qs on usr.question_section_id = qs.section_id
where usr.user = #{0,jdbcType=INTEGER}
4.完成