前言

SQL报错

    "errorMsg": "PreparedStatementCallback; SQL [select  wi.id,pat.text_value from writeoff_instance wi          left join writeoff_detail wd on wi.id=wd.writeoff_instance_id          left join paperless_accessories_b_rel pabr  on wi.writeoff_archive_id=pabr.related_archive_id          left join paperless_accessories_text pat on pat.paperless_accessories_id=pabr.paperless_accessories_id where  wi.status  not in ('-1','15','16') and wi.create_date>=CURRENT_DATE - INTERVAL '? months' and     wd.cost_center_code=?     and pat.text_key=?     and wi.province_code=?     and pat.text_value !='' and pat.text_value  is not null group by pat.text_value,wi.id ]; 栏位索引超过许可范围:4,栏位数:3。; nested exception is org.postgresql.util.PSQLException: 栏位索引超过许可范围:4,栏位数:3。",
    "type": "400"

原因

  1. SQL有字段不能被?号替换
    如PG的CURRENT_DATE - INTERVAL '3 months' 这里3因为是字符内部 就无法传值进去 可以选择拼接SQL 或者写死
  2. #{}
    在xml中,#{}即使注释了也会被扫描到
    解决方法:删除带#{}的注释
    Mybatis - PSQLException: 栏位索引超过许可范围:4,栏位数:3

更多推荐