该方式是否可以解决不同数据库字段别名的不同写法问题,如果是多表联查(多表有命名一样的字段), @Result可以准确定位sql中具体相关表的字段呢?回家测试一下!!!
public interface TestMapper {
@Select("SELECT " +
"t1.APPLY_NO," +
"t1.CARD_IS_LONG_VALID," +
"t1.SPELL_NAME ,"+
"t1.EDUCATION , " +
"t1.MARITAL_STATUS "+
"FROM " +
"identity_info t1 " +
"WHERE " +
" t1.apply_no = #{applyNo}")
@Results({
@Result(property = "applyNo", column = "APPLY_NO"),
@Result(property = "cardIsLongValid", column = "CARD_IS_LONG_VALID"),
@Result(property = "spellName", column = "SPELL_NAME"),
@Result(property = "education", column = "EDUCATION"),
@Result(property = "maritalStatus", column = "MARITAL_STATUS")
})
Map queryBasicInfo(Map paramMap);
@SelectProvider(type = SelectBasicInfo.class,method = "selectBasicInfo")
List<Map> selectBasicInfo(Map paramMap);
public class SelectBasicInfo{
public String selectBasicInfo(){
return new SQL(){
{
SELECT("APPLY_NO as applyNo");
SELECT("CARD_IS_LONG_VALID as cardIsLongValid");
SELECT("SPELL_NAME as spellName ");
SELECT("EDUCATION as education ");
SELECT("MARITAL_STATUS as maritalStatus ");
FROM("identity_info");
WHERE("apply_no = #{applyNo} ");
WHERE("MARITAL_STATUS = '1' ");
ORDER_BY("created_date desc");
}
}.toString();
}
}
}