Mybatis的写法
南陈 2018-07-19 10:41:32 第一种:在java里面写。
@Select("select bureau_code from drt_opr_area")
List<String> getAllAreas();
第二种:在xml里面写。
<select id="selectList" resultMap="BaseResultMap" parameterType="com.csg.intshop.entity.DrtShopConfig">
select
<include refid="BaseColumnList" />
from drt_shop_config
where 1=1
<include refid="BaseCustomQueryCondition" />
</select>
想问问:在什么情况下写java代码好,在什么情况下选中写xml好?如果是全表查询,这两种写法在性能有没有区别?
比如:当表字段比较多的时候,全表查询写xml看起来比较简洁,可读性强。