saboluo opened a new issue #4306: Why do distributed primary keys need to be 
retrieved in reverse order in 
ShardingGeneratedKeyInsertValueParameterRewriter.rewrite
URL: https://github.com/apache/incubator-shardingsphere/issues/4306
 
 
   ## Question
   
   **For English only**, other languages will not accept.
   
   Before asking a question, make sure you have:
   
   - Googled your question.
   - Searched open and closed [GitHub 
issues](https://github.com/apache/incubator-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 **more than 7 days** and we cannot reproduce it on current 
information, we will **close it**.
   
   source code
   class ShardingGeneratedKeyInsertValueParameterRewriter
   
   `public void rewrite(final ParameterBuilder parameterBuilder, final 
SQLStatementContext sqlStatementContext, final List<Object> parameters) {
           
Preconditions.checkState(sqlRouteResult.getGeneratedKey().isPresent());
           ((GroupedParameterBuilder) 
parameterBuilder).setDerivedColumnName(sqlRouteResult.getGeneratedKey().get().getColumnName());
           **Iterator<Comparable<?>> generatedValues = 
sqlRouteResult.getGeneratedKey().get().getGeneratedValues().descendingIterator();**
           int count = 0;
           int parametersCount = 0;
           for (List<Object> each : ((InsertSQLStatementContext) 
sqlStatementContext).getGroupedParameters()) {
               parametersCount += ((InsertSQLStatementContext) 
sqlStatementContext).getInsertValueContexts().get(count).getParametersCount();
               Comparable<?> generatedValue = generatedValues.next();
               if (!each.isEmpty()) {
                   ((GroupedParameterBuilder) 
parameterBuilder).getParameterBuilders().get(count).addAddedParameters(parametersCount,
 Lists.<Object>newArrayList(generatedValue));
               }
               count++;
           }
       }`
   
     
   
   
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to