在spring框架下,sql语句无疑是bug最多的地方,首先第一个就是不能注释,注释的代码可能被--注释无效!第二个就是在程序运行过程中,按理来说修改sql语句并不会影响目前的运行,代码部分不会,但是sql语句如果在运行过程中修改,那程序就会有问题!
2024-1-12补充:
sql BUG 三:
比如在一下添加两个字段,检查没有任何问题,启动tomcat,居然无法将这两个字段查询出来!当你发现真的一点问题都没有的时候,请重启idea,我是重启后就成功查出来了。
----------
2024.3补充
select a.orders_id,a.order_type,a.name,a.orders_date,a.deal_num,a.shop_id,a.order_state,a.pay_time,a.platform_order_id
from t_erp_orders a
inner join t_erp_shop b on a.shop_id = b.shop_id and a.enterprise_id = b.enterprise_id
where a.is_refund_order=1 and a.state = 1 and b.state = 1 and b.is_use = 1 and a.enterprise_id = 1091 and a.order_type = 0 and a.is_split != 1 and a.is_retry != 1
and b.platform_type = 8 and a.order_state in (0,1,2,3)
and a.shop_id = 1257
order by a.orders_date asc
以上是一个查询语句,但是我发现查询到的订单数据,居然有很多is_refund_order=0的订单,我是debug时候,看数据发现的,我明明已经where a.is_refund_order=1,于是我就把sql语句直接在navicat中运行,发现查到的数据是正确的,经过深思发现,我select中的对象并没有is_refund_order,傻了,我没查的居然给我返回0这个数据。。。。这是bug吧!!!不管怎样顺利解决了。