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

   ## 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?
   5.4.0
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-JDBC
   ### Expected behavior
   I want to use sharedsphere+mybaties to perform batch database processing 
operations; when I use the following code to operate, I can't get the key 
returned by inserting;
   eg:
   connection = sqlSession. getConnection();
   preparedStatement = connection.prepareStatement(sql, 
Statement.RETURN_GENERATED_KEYS);
   ... //set params
   preparedStatement. addBatch();
   ...
   preparedStatement. executeBatch();
   ...
   resultSet = preparedStatement. getGeneratedKeys();
   while(resultSet.next()){//Always return false; can you tell me why? Am I 
using it wrong?
        //Can't enter the modified code, resulting in not getting the key 
returned by the database operation
   }
   ### Actual behavior
   it always get empty resultSet;
   ### Reason analyze (If you can)
   When I call getGeneratedKeys, the batchPreparedStatementExecutor has been 
cleared by the finally module of executeBatch calling clearBatch() 
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule 
configuration, when exception occur etc.
   SQL:
   insert into targets_system (subject,`code`, `name`, `count`, 
hierarchy,create_by,update_by)
           values 
(#{subject},#{code},#{name},#{count},#{hierarchy},#{createBy},#{updateBy})
   Config:
   
   rules:
   - !SINGLE
     tables:
       - "*.*"
   - !SHARDING
     tables:
       quiz_question_reply:
         actualDataNodes: ds_1.quiz_question_reply_202307
         tableStrategy:
           standard:
             shardingColumn: create_on #任务创建时间 
mybaties的xml-sql语句配置必须含有create_on字段
             shardingAlgorithmName: quiz_question_reply_create_on
       quiz_member:
         actualDataNodes: ds_1.quiz_member_202307
         tableStrategy:
           standard:
             shardingColumn: create_on #任务创建时间 
mybaties的xml-sql语句配置必须含有create_on字段
             shardingAlgorithmName: quiz_member_create_on
       quiz_student_report:
         actualDataNodes: ds_1.quiz_student_report_${0..49}
         tableStrategy:
           standard:
             shardingColumn: student_id
             shardingAlgorithmName: quiz_student_report_inline
     shardingAlgorithms:
       quiz_question_reply_create_on:
         type: CLASS_BASED
         props:
           sufixFormat: yyyyMM
           strategy: STANDARD
           algorithmClassName: 
com.yeker.sdk.sharding.algorithm.DateShardingAlgorithm
       quiz_member_create_on:
         type: CLASS_BASED
         props:
           sufixFormat: yyyyMM
           strategy: STANDARD
           algorithmClassName: 
com.yeker.sdk.sharding.algorithm.DateShardingAlgorithm
       quiz_student_report_inline:
         type: INLINE
         props:
           algorithm-expression: quiz_student_report_${student_id % 50}
   
   props:
     sql-show: true
   
   Result:
   just get empty ResultSet when call preparedStatement. getGeneratedKeys();
   
   ### Example codes for reproduce this issue (such as a github link).
   


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