java Date的对象作为参数传入Mapper.xml里, 查询日期字段等于这个Date的记录, 没有记录被查到, 代码如下:
<select id="selectByDate" resultMap="productMap">
select * from product where create_date = #{date,jdbcType=DATE
</select>
<select id="selectByDate" resultMap="productMap">
select * from product where create_date = #{date}
</select>
试了下在MySQL里能直接用字符串查到
SELECT * FROM product WHERE create_date = '2019-10-10 00:00:00'
一直搜不到解决方法, 求助各位
你用的date直接等于,会有一个转换过程,肯定不匹配,一般查日期时间都是通过范围
select * from product where create_date = date_format(#{date}, '%Y-%m-%d %H:%i:%s')
要看下你的数据库字段是什么类型的