1
回答
Sharding-JDBC SQL-多个字段排序-语法解析出错
利用AWS快速构建适用于生产的无服务器应用程序,免费试用12个月>>>   

版本从1.4.2升级到1.5.3后,SQL出现解析错误,未升级之前是可以正确执行的,SQL中的acp_deduct_batch_details按照contract_date分库分表,acp_agreement也是按照contract_date分库分表,该SQL按照参数解析后,应该会落在同一个数据库中。

是不是因为升级后,排序的字段需要在前面添加别名details也还是解析出错,麻烦看下,谢谢了

SQL:

select

details.app_code,details.app_product_type, details.deduct_batch_detail_id, details.deduct_batch_id,

details.contract_id,details.party_type,details.party_id, agreement.agreement_id,agreement.agreement_no, details.remain_amount,details.deduct_date

from acp_deduct_batch_details details

inner join acp_agreement agreement on details.contract_id = agreement.contract_id and details.party_type = agreement.party_type and details.party_id = agreement.party_id

where details.contract_date between ? and ? and details.deduct_result = 'Create' and details.deduct_batch_id = ? and agreement.contract_date between ? and ? order by ?

 

参数:

20170801(Integer), 20170831(Integer), 17091305851859017146368(String), 20170801(Integer), 20170831(Integer), contract_id, party_type, party_id (String)

 

异常:

Caused by: com.dangdang.ddframe.rdb.sharding.parsing.parser.exception.SQLParsingException: SQL syntax error, token is 'END', literals is ''.
        at com.dangdang.ddframe.rdb.sharding.parsing.parser.clause.OrderByClauseParser.parseSelectOrderByItem(OrderByClauseParser.java:81) ~[sharding-jdbc-core-1.5.3.jar:na]
        at com.dangdang.ddframe.rdb.sharding.parsing.parser.clause.OrderByClauseParser.parse(OrderByClauseParser.java:51) ~[sharding-jdbc-core-1.5.3.jar:na]
        at com.dangdang.ddframe.rdb.sharding.parsing.parser.sql.dql.select.AbstractSelectParser.parseOrderBy(AbstractSelectParser.java:125) ~[sharding-jdbc-core-1.5.3.jar:na]
        at com.dangdang.ddframe.rdb.sharding.parsing.parser.dialect.mysql.sql.MySQLSelectParser.parseInternal(MySQLSelectParser.java:54) ~[sharding-jdbc-core-1.5.3.jar:na]
        at com.dangdang.ddframe.rdb.sharding.parsing.parser.sql.dql.select.AbstractSelectParser.parseInternal(AbstractSelectParser.java:81) ~[sharding-jdbc-core-1.5.3.jar:na]
        at com.dangdang.ddframe.rdb.sharding.parsing.parser.sql.dql.select.AbstractSelectParser.parse(AbstractSelectParser.java:68) ~[sharding-jdbc-core-1.5.3.jar:na]
        at com.dangdang.ddframe.rdb.sharding.parsing.parser.sql.dql.select.AbstractSelectParser.parse(AbstractSelectParser.java:46) ~[sharding-jdbc-core-1.5.3.jar:na]
        at com.dangdang.ddframe.rdb.sharding.parsing.SQLParsingEngine.parse(SQLParsingEngine.java:50) ~[sharding-jdbc-core-1.5.3.jar:na]
        at com.dangdang.ddframe.rdb.sharding.routing.router.ParsingSQLRouter.parse(ParsingSQLRouter.java:71) ~[sharding-jdbc-core-1.5.3.jar:na]
        at com.dangdang.ddframe.rdb.sharding.routing.PreparedStatementRoutingEngine.route(PreparedStatementRoutingEngine.java:55) ~[sharding-jdbc-core-1.5.3.jar:na]
        at com.dangdang.ddframe.rdb.sharding.jdbc.core.statement.ShardingPreparedStatement.route(ShardingPreparedStatement.java:149) ~[sharding-jdbc-core-1.5.3.jar:na]
        at com.dangdang.ddframe.rdb.sharding.jdbc.core.statement.ShardingPreparedStatement.execute(ShardingPreparedStatement.java:139) ~[sharding-jdbc-core-1.5.3.jar:na]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_91]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_91]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_91]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_91]
        at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:62) ~[mybatis-3.2.8.jar:3.2.8]
        at com.sun.proxy.$Proxy161.execute(Unknown Source) ~[na:na]
        at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:59) ~[mybatis-3.2.8.jar:3.2.8]
        at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:73) ~[mybatis-3.2.8.jar:3.2.8]
        at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:60) ~[mybatis-3.2.8.jar:3.2.8]
        at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:267) ~[mybatis-3.2.8.jar:3.2.8]
        at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:137) ~[mybatis-3.2.8.jar:3.2.8]
        at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:120) ~[mybatis-3.2.8.jar:3.2.8]
        at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:108) ~[mybatis-3.2.8.jar:3.2.8]
        ... 28 common frames omitted

 

<无标签>
举报
顶部