问题
下面是我的mapper.xml中的sql,在查询的时候一直不走我写的分片算法
(我的分片算法 根据create_time按季度分片)
mybatis-mapper.xml
<!--根据时间范围获取订单列表-->
<select id="getListByFunction" resultType="com.chao.domain.vo.OrderListVO">
select
<include refid="Base_Column_List"/>
from order_info
where date(create_time) between #{startTime} and #{endTime}
order by create_time desc
</select>
解决方案
验证分片键是否确实存在于查询的SQL语句中,并且其值可以被ShardingJDBC正确识别。
原因
where date(create_time) between #{startTime} and #{endTime}
where后面的语句中date(create_time)识别不了
修改
<!--根据时间范围获取订单列表-->
<select id="getListByFunction" resultType="com.chao.domain.vo.OrderListVO">
select
<include refid="Base_Column_List"/>
from order_info
where create_time between #{startTime} and #{endTime}
order by create_time desc
</select>