最近项目中需要实现动态列,百思之后终于想到了方法:现分享给大家
<!-- 根据条件分页查询信息 -->
<select id="listPageDetail" parameterType="Detail" statementType="STATEMENT"
resultMap="DetailResultMap">
select
id ${tempsql}
from order_detail where 1 =1
order by id desc
</select>
其中最主要的有两点:
1.statementType:这里包含三个属性STATEMENT(非预编译)、PREPARED(预编译、默认是这个)、CALLABLE(存储过程)
2.如果选用了STATEMENT,那么sql中的获取变量只能用${},切记