我们就看mybatis的实现代码。
public interface PayPabReceiptDownloadMapper extends BaseMapper<PayPabReceiptDownload> {
/**
* 根据日期查询下载记录
* @param createDate
* @return
*/
List<PayPabReceiptDownload> queryByCreateDate(String createDate);
}
再看xml文件对应里的sql:
<select id="queryByCreateDate" resultType="com.emax.channel.provider.modules.receipt.entity.PayPabReceiptDownload">
select * from pay_pab_receipt_download where file_status = 2
and DATE_FORMAT(create_date,'%Y-%m-%d') = #{createDate}
</select>
不靠谱!
不靠谱说明:
- 方法queryByCreateDate的参数createDate,如果不看到里面的sql语句,你能知道应该传什么值? 如何靠谱?你猜!
- 再说sql,因为在字段上用了函数,导致sql执行变慢,即使create_date字段有索引,这样加了函数的sql也无法命中索引。