You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "archlevel (via GitHub)" <gi...@apache.org> on 2023/08/01 01:33:46 UTC

[GitHub] [shardingsphere] archlevel opened a new issue, #27600: shardingsphere 5.4.0+mybaties; when getGeneratedKeys it return empty ResultSet when after executeBatch

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: notifications-unsubscribe@shardingsphere.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] shardingsphere 5.4.0+mybaties; when getGeneratedKeys it return empty ResultSet when after executeBatch [shardingsphere]

Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu commented on issue #27600:
URL: https://github.com/apache/shardingsphere/issues/27600#issuecomment-2231044796

   The issue involves other third-party dependencies, but our focus is solely on ShardingSphere itself. Since ShardingSphere implements the JDBC interface, standard applications should be functional. We wish to allocate more effort towards enhancing the current version, and therefore will no longer handle such issues. Please read the documentation or provide more effective information when submitting an issue.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] shardingsphere 5.4.0+mybaties; when getGeneratedKeys it return empty ResultSet when after executeBatch [shardingsphere]

Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu closed issue #27600: shardingsphere 5.4.0+mybaties;  when getGeneratedKeys it return empty ResultSet when after executeBatch
URL: https://github.com/apache/shardingsphere/issues/27600


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] azexcy commented on issue #27600: shardingsphere 5.4.0+mybaties; when getGeneratedKeys it return empty ResultSet when after executeBatch

Posted by "azexcy (via GitHub)" <gi...@apache.org>.
azexcy commented on issue #27600:
URL: https://github.com/apache/shardingsphere/issues/27600#issuecomment-1659762028

   I find the official doc, 
   
   Limited supported SQL:
   
   - When using `getGeneratedKeys` interface of JDBC specification to return auto-increment key, it is necessary to use a distributed key generator that supports auto-increment, and does not support other types of distributed key generators
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] github-actions[bot] commented on issue #27600: shardingsphere 5.4.0+mybaties; when getGeneratedKeys it return empty ResultSet when after executeBatch

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #27600:
URL: https://github.com/apache/shardingsphere/issues/27600#issuecomment-1701708972

   There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org