1. 程式人生 > >mycat執行報錯:java.sql.SQLException: java.lang.IllegalArgumentException: all columns in order by clause

mycat執行報錯:java.sql.SQLException: java.lang.IllegalArgumentException: all columns in order by clause

普通sql語句:

SELECT  REC_ID,ORDER_UPDATE_RULE,ACTIVITY_ID FROM   PLT_ACTIVITY_INFO 
WHERE ((ORDER_GEN_RULE = 1 OR ORDER_GEN_RULE = 2 )
AND TENANT_ID = 'uni076'
AND ACTIVITY_ID = '112202'
AND ACTIVITY_STATUS = '1'
) ORDER BYLAST_ORDER_CREATE_TIME DESC

在mycat庫直接執行沒有問題:

程式執行報錯:

### Error querying database. Cause: java.sql.SQLException: java.lang.IllegalArgumentException: all columns in order by clause should be in the selected column list!LAST_ORDER_CREATE_TIME

### The error may exist in com/bonc/busi/orderschedule/mapper/OrderMapper.java (best guess)

### The error may involve com.bonc.busi.orderschedule.mapper.OrderMapper.selectUpdateRuleByActivity-Inline

### The error occurred while setting parameters ### SQL: SELECT REC_ID,ACTIVITY_ID,ORDER_UPDATE_RULE FROM PLT_ACTIVITY_INFO WHERE ( (ORDER_GEN_RULE = 1 OR ORDER_GEN_RULE = 2) AND TENANT_ID='uni076' AND ACTIVITY_ID = '112202' AND ACTIVITY_STATUS='1' ) ORDER BY LAST_ORDER_CREATE_TIME DESC

### Cause: java.sql.SQLException: java.lang.IllegalArgumentException: all columns in order by clause should be in the selected column list!LAST_ORDER_CREATE_TIME ; uncategorized SQLException for SQL []; SQL state [HY000]; error code [1105]; java.lang.IllegalArgumentException: all columns in order by clause should be in the selected column list!LAST_ORDER_CREATE_TIME; nested exception is java.sql.SQLException: java.lang.IllegalArgumentException: all columns in order by clause should be in the selected column list!LAST_ORDER_CREATE_TIME

從錯誤中發現將LAST_ORDER_CREATE_TIME加在查詢欄位中:正常