NOLouser opened a new issue, #10283:
URL: https://github.com/apache/shardingsphere/issues/10283

   ## Bug Report
   
   **For English only**, other languages will not accept.
   
   Before report a bug, make sure you have:
   
   - Searched open and closed [GitHub 
issues](https://github.com/apache/shardingsphere/issues).
   - Read documentation: [ShardingSphere 
Doc](https://shardingsphere.apache.org/document/current/en/overview).
   
   Please pay attention on issues you submitted, because we maybe need more 
details. 
   If no response anymore and we cannot reproduce it on current information, we 
will **close it**.
   
   Please answer these questions before submitting your issue. Thanks!
   
   ### Which version of ShardingSphere did you use?
   build.gradle:
   `compile group: 'org.apache.shardingsphere', name: 
'shardingsphere-jdbc-core-spring-boot-starter', version: "5.0.0-alpha"`
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-JDBC
   
   ### Expected behavior
   In one transaction, I'm trying to execute two same logic sqls with different 
hint. I think that it will execute two actual sql in different sharding table .
   ```
   @Transactional
   public Object hello(){
       try (HintManager hintManager=HintManager.getInstance();){
           // 指定查询的分表
           hintManager.addTableShardingValue("t_order_hint","40");
           TOrderExtend 
tOrder=tOrderExtendMapper.selectOne(Wrappers.<TOrderExtend>lambdaQuery().eq(TOrderExtend::getUserId,9));
           LOGGER.info(tOrder.toString());
       }
   
       try (HintManager hintManager=HintManager.getInstance();){
           // 指定查询的分表
           hintManager.addTableShardingValue("t_order_hint","39");
           TOrderExtend 
tOrder=tOrderExtendMapper.selectOne(Wrappers.<TOrderExtend>lambdaQuery().eq(TOrderExtend::getUserId,9));
           LOGGER.info(tOrder.toString());
       }
   
       Map<String,String> result=new HashMap<>();
       result.put("word","hello, world!");
   
       return result;
   }
   ```
   
   ### Actual behavior
   ```
   [INFO] 2021-05-08 15:59:26.977 http-nio-9014-exec-2 
org.apache.shardingsphere.infra.executor.sql.log.SQLLogger:74 - Logic SQL: 
SELECT  order_id,user_id,address_id,status,datetime  FROM t_order_hint 
    
    WHERE (user_id = ?)
   [INFO] 2021-05-08 15:59:26.978 http-nio-9014-exec-2 
org.apache.shardingsphere.infra.executor.sql.log.SQLLogger:74 - SQLStatement: 
MySQLSelectStatement(limit=Optional.empty, lock=Optional.empty)
   [INFO] 2021-05-08 15:59:26.978 http-nio-9014-exec-2 
org.apache.shardingsphere.infra.executor.sql.log.SQLLogger:74 - Actual SQL: ds 
::: SELECT  order_id,user_id,address_id,status,datetime  FROM t_order_40 
    
    WHERE (user_id = ?) ::: [9]
   [INFO] 2021-05-08 15:59:27.010 http-nio-9014-exec-2 
com.nolouser.demo.service.impl.TOrderServiceImpl:42 - 
TOrder{orderId=548438947156963329, userId=9, addressId=9, status=INSERT_TEST, 
datetime=2020-12-23 09:40:34}
   [INFO] 2021-05-08 15:59:27.011 http-nio-9014-exec-2 
com.nolouser.demo.service.impl.TOrderServiceImpl:49 - 
TOrder{orderId=548438947156963329, userId=9, addressId=9, status=INSERT_TEST, 
datetime=2020-12-23 09:40:34}
   ```
   From log, we could see that it only executed the first logic sql.
   
   ### Reason analyze (If you can)
   In the way of executing two same sqls in one transaction, mybatis-plus  will 
actually execute the first one, and gets result of the second one from  cache, 
so ShardingSphere will not work for the second logic sql.
   ![the first logic 
sql](https://user-images.githubusercontent.com/40658641/117532036-169ca380-b018-11eb-96de-48eae5825b4d.png)
   ![the second logic 
sql](https://user-images.githubusercontent.com/40658641/117532124-86129300-b018-11eb-9e89-aa05d3e401f7.png)
   
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule 
configuration, when exception occur etc.
   
   
   ### Example codes for reproduce this issue (such as a github link).
   [example codes](https://github.com/NOLouser/shardingsphere-demo)
   com.nolouser.demo.service.impl.TOrderServiceImpl#hello
   
org.apache.ibatis.executor.BaseExecutor#query(org.apache.ibatis.mapping.MappedStatement,
 java.lang.Object, org.apache.ibatis.session.RowBounds, 
org.apache.ibatis.session.ResultHandler, org.apache.ibatis.cache.CacheKey, 
org.apache.ibatis.mapping.BoundSql)


-- 
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