puppylpg commented on issue #14100:
URL: 
https://github.com/apache/shardingsphere/issues/14100#issuecomment-1537966546

   > Still meets the same error if there are many(50+) parameters in the sql. 
Version: **shardingsphere-jdbc-core:5.1.1**:
   > 
   > ```
   > ### Cause: java.lang.ClassCastException: java.lang.String cannot be cast 
to java.lang.Integer
   >    at 
org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
 ~[mybatis-3.5.6.jar:3.5.6]
   >    at 
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:149)
 ~[mybatis-3.5.6.jar:3.5.6]
   >    at 
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140)
 ~[mybatis-3.5.6.jar:3.5.6]
   >    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
~[na:1.8.0_292]
   >    at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
~[na:1.8.0_292]
   >    at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 ~[na:1.8.0_292]
   >    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_292]
   >    at 
org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:426)
 ~[mybatis-spring-2.0.5.jar:2.0.5]
   >    ... 15 common frames omitted
   > Caused by: java.lang.ClassCastException: java.lang.String cannot be cast 
to java.lang.Integer
   >    at 
org.apache.shardingsphere.infra.binder.segment.select.pagination.PaginationContext.getValue(PaginationContext.java:57)
 ~[shardingsphere-infra-binder-5.1.1.jar:5.1.1]
   >    at 
org.apache.shardingsphere.infra.binder.segment.select.pagination.PaginationContext.<init>(PaginationContext.java:50)
 ~[shardingsphere-infra-binder-5.1.1.jar:5.1.1]
   >    at 
org.apache.shardingsphere.infra.binder.segment.select.pagination.engine.LimitPaginationContextEngine.createPaginationContext(LimitPaginationContextEngine.java:38)
 ~[shardingsphere-infra-binder-5.1.1.jar:5.1.1]
   >    at 
org.apache.shardingsphere.infra.binder.segment.select.pagination.engine.PaginationContextEngine.createPaginationContext(PaginationContextEngine.java:57)
 ~[shardingsphere-infra-binder-5.1.1.jar:5.1.1]
   >    at 
org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext.setUpParameters(SelectStatementContext.java:338)
 ~[shardingsphere-infra-binder-5.1.1.jar:5.1.1]
   >    at 
org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.createLogicSQL(ShardingSpherePreparedStatement.java:478)
 ~[shardingsphere-jdbc-core-5.1.1.jar:5.1.1]
   >    at 
org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.execute(ShardingSpherePreparedStatement.java:358)
 ~[shardingsphere-jdbc-core-5.1.1.jar:5.1.1]
   >    at sun.reflect.GeneratedMethodAccessor57.invoke(Unknown Source) ~[na:na]
   >    at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 ~[na:1.8.0_292]
   >    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_292]
   >    at 
org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:59)
 ~[mybatis-3.5.6.jar:3.5.6]
   >    at com.sun.proxy.$Proxy210.execute(Unknown Source) ~[na:na]
   >    at 
org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:64)
 ~[mybatis-3.5.6.jar:3.5.6]
   >    at 
org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79)
 ~[mybatis-3.5.6.jar:3.5.6]
   >    at sun.reflect.GeneratedMethodAccessor56.invoke(Unknown Source) ~[na:na]
   >    at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 ~[na:1.8.0_292]
   >    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_292]
   >    at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:63) 
~[mybatis-3.5.6.jar:3.5.6]
   >    at com.sun.proxy.$Proxy209.query(Unknown Source) ~[na:na]
   >    at 
com.baomidou.mybatisplus.core.executor.MybatisSimpleExecutor.doQuery(MybatisSimpleExecutor.java:69)
 ~[mybatis-plus-core-3.4.1.jar:3.4.1]
   >    at 
org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:325)
 ~[mybatis-3.5.6.jar:3.5.6]
   >    at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156) 
~[mybatis-3.5.6.jar:3.5.6]
   >    at 
com.baomidou.mybatisplus.core.executor.MybatisCachingExecutor.query(MybatisCachingExecutor.java:165)
 ~[mybatis-plus-core-3.4.1.jar:3.4.1]
   >    at 
com.baomidou.mybatisplus.core.executor.MybatisCachingExecutor.query(MybatisCachingExecutor.java:92)
 ~[mybatis-plus-core-3.4.1.jar:3.4.1]
   >    at 
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147)
 ~[mybatis-3.5.6.jar:3.5.6]
   >    ... 21 common frames omitted
   > ```
   > 
   > sql:
   > 
   > > SELECT sk.U_ID as kol_id, same_product, same_company, same_industry      
   FROM SK_TABLE sk         JOIN (SELECT ton.K_ID,         
MAX(IF(ob.CUSTOMER_PRODUCT_ID = ?, 1, 0)) AS same_product,         
MAX(IF(ob.CUSTOMER_COMPANY_ID = ?, 1, 0)) AS same_company,         
MAX(IF(ob.CUSTOMER_INDUSTRY_TYPE = ?, 1, 0)) AS same_industry         FROM 
OB_TABLE ob         INNER JOIN TO_TABLE ton ON ob.ID = ton.OB_ID         GROUP 
BY ton.K_ID) AS history_task ON sk.U_ID = history_task.K_ID         LEFT JOIN 
KM_TABLE km on sk.U_ID = km.U_ID          WHERE sk.PLATFORM = ?                 
             AND sk.country IN                 (                     ?          
       ,                     ?                 ,                     ?          
       ,                     ?                 ,                     ?          
       ,                     ?                 ,                     ?          
       ,                     ?                 ,                     ?          
       ,     
                 ?                 ,                     ?                 ,    
                 ?                 ,                     ?                 ,    
                 ?                 ,                     ?                 ,    
                 ?                 ,                     ?                 ,    
                 ?                 ,                     ?                 ,    
                 ?                 ,                     ?                 ,    
                 ?                 ,                     ?                 ,    
                 ?                 ,                     ?                 ,    
                 ?                 ,                     ?                 ,    
                 ?                 ,                     ?                 ,    
                 ?                 ,                     ?                 ,    
                 ?                 ,                     ?                 ,    
                 ?                 ,  
                    ?                 ,                     ?                 , 
                    ?                 ,                     ?                 , 
                    ?                 ,                     ?                 , 
                    ?                 ,                     ?                 , 
                    ?                 ,                     ?                 , 
                    ?                 ,                     ?                 , 
                    ?                 ,                     ?                 , 
                    ?                 ,                     ?                 , 
                    ?                 ,                     ?                 , 
                    ?                 ,                     ?                 , 
                    ?                 ,                     ?                 , 
                    ?                 )          ORDER BY same_product desc,    
     same_company desc,         same_i
 ndustry desc,         km.MEDIA desc,                  IF(sk.K_L = 4, 3, 
IF(sk.K_L = 1, 3, IF(sk.K_L = 2, 2, IF(sk.K_L = 3, 1, sk.K_L)))) desc,         
sk.C_TIMES desc,         IF(sk.CO_TYPE = 1, 1, 0) desc,         sk.H_P desc,    
     km.V_R desc         limit ?, ?
   > 
   > 
![image](https://user-images.githubusercontent.com/9563181/236622889-22a513ac-de27-4544-92e5-c9c26791152d.png)
   > 
   > delete the `AND sk.country IN ( ... )` clause to eliminate these many 
parameters seems ok. Any hints about the bug? thanks
   
   I find that the `where` clause can't be put after `join`, and after 
reversing them, there's no parameter cast error ┑( ̄Д  ̄)┍


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to