You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/10/06 11:52:00 UTC

[GitHub] [shardingsphere] sabz90 opened a new issue #7703: Can not update sharding key, logic table: [**], column: [**]

sabz90 opened a new issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703


   I am using Spring Data JPA with Hibernate (with mysql), Spring Boot 2 and SS 4.1.1.
   Things were working fine with 4.0.0-RC1. After i updated version to 4.1.1 i get :-
   `
   org.apache.shardingsphere.core.exception.ShardingException: Can not update sharding key, logic table: [ACCOUNT_INFO], column: [org.apache.shardingsphere.sql.parser.sql.segment.dml.assignment.AssignmentSegment@5afa0b1a].
   `
   
   My Table ACCOUNT_INFO looks like:-
   
   - id
   - version
   - account_id  **(THIS IS THE SHARD COLUMN CONFIGURED)**
   - zip
   - name
   
   The hibernate generated sql query for update looks like :-
   
   `update ACCOUNT_INFO set name=??, account_id=??, zip=??, version=?? where id = ?? and version = ??
   `
   
   This statement throws the exception when executed through DAL:-
   org.apache.shardingsphere.core.exception.ShardingException: Can not update sharding key, logic table: [ACCOUNT_INFO], column: [org.apache.shardingsphere.sql.parser.sql.segment.dml.assignment.AssignmentSegment@5afa0b1a].
   
   This was not happening in 4.0.0-RC1.
   
   I debugged a bit and I found that this expects **account_id** to be present in the where clause. Unfortunately, Spring Data JPA does not provide a way for me to specify what columns will be there in where clause. I do not want to write custom JPA query because then version management will have to be done manually and also will become tedious as my table has large columns.
   
   I tried using the hint manager but it didn't work :-
   
   ```
           try(HintManager hintManager = HintManager.getInstance()) {
             hintManager
                 .addDatabaseShardingValue("ACCOUNT_INFO", accountEntity.getAccountId());
             hintManager.addTableShardingValue("ACCOUNT_INFO", accountEntity.getAccountId());
   
             session.update(accountEntity);
             transaction.commit();
           }
   ```
   
   How do i solve this ??


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] sabz90 commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
sabz90 commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-712358482


   > The query does not change the Sharding key of the table. If that value does not appear in SET statement
   > 
   > > update ACCOUNT_INFO set name=??, account_id=??, zip=??, version=?? where id = ?? and version = ??
   > 
   > Sorry? `account_id` is a sharding key and in set clause, isn't it?
   
   Yes, but the value is same as what was already present in the DB. But yes, there's no way for sharding sphere to know if the new value is equal to the old value, without it being specified in the where clause.  Unfortunately, hibernate doesn't provide a way to include custom columns in the where clause


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-716465136


   Hi, @heqiao  Thanks for your kind explanation. 
   
   Actually, the idea I mentioned before is not an optimal solution for `SET shardingKey`. If users really want to update shardingKey, shardingsphere should execute that update and move the actual row to the new target table. 
   But for now, we can take it as a better solution to balance updating safety and JPA case.
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero edited a comment on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
tristaZero edited a comment on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-705952634


   @sabz90 Are you going to update the sharding key of logic table? FYI, If you updated the value of sharding key, it would be possible to move this row to another table or db.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] strongduanmu commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-1068798094


   @lMasterSparkl `update post set update_dt=?, did=?, base_like=?, base_pv=?, base_share=?, discuss=?, game_id=?, hot=?, images=?, is_delete=?, is_official=?, is_top=?, level=?, official_head=?, official_nick_name=?, official_title=?, post_id=?, pv=?, reply1did=?, reply1id=?, reply2did=?, reply2id=?, reply_did=?, share=?, tag=?, text=?, topic_id=?, topic_name=?, up=?, videos=? where id=?` 
   
   Judging from your sql, you are trying to update `dids` with id = ?, so this exception occurs. 
   
   There are two ways to solve it, 1. Do not update the did field, 2. Update the did field, and add the did condition of the same routing result to the where segment.


-- 
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] tristaZero commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-705952634


   @sabz90 Are you going to update the sharding key of logic table? FYI, If you update the value of sharding key, it is possible to move this row to another table or db.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] sabz90 edited a comment on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
sabz90 edited a comment on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-737068772


   > @strongduanmu Thank you for diving into it. @tristaZero My apologies that the proposed solution may not work as I originally agreed. The where clause doesn't contain the sharding key.
   > 
   > e.g. `update ACCOUNT_INFO set name=??, account_id=??, zip=??, version=?? where id = ??` was the generated sql with account_id being the sharding key. The `shardingValue` is empty in the code @strongduanmu posted (ShardingUpdateStatementValidator.java).
   > 
   > ![image](https://user-images.githubusercontent.com/3125184/100831541-d7d84100-341a-11eb-85d8-3336a726d57e.png)
   > 
   > So the logic may be
   > 
   > ```
   > if (no shardingKey in SET Clause)
   >     then PASS
   > else if (no shardingKey in WHERE Clause)
   >     then append sharding column and value to WHERE Clause
   > else if (the value of shardingKey in SET Clause == the value of shardingKey in WHERE Clause)
   >     then PASS
   > else
   >     then an exception
   > ```
   
   The second condition will fix this issue but it is a risky option - we are just assuming that the user did not intend to put the sharding column in the SET clause. 
   
   ```
   else if (no shardingKey in WHERE Clause)
       then append sharding column and value to WHERE Clause
   ```
   
   So a safer option would be to define an Annotation, something like "@ForceWhereClause" which should then indicate to sharding-sphere that it has to use the value from SET clause and put in a where clause along in the final statement.
   
   For now i have solved the problem by using CompositeKey @IdClass method , which makes hibernate include the column in where clause, but it's more of a hack since the sharding column is not really a composite key in the database level.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] heqiao commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
heqiao commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-714274455


   > > There is indeed a workaround - Embed the primary key and sharding key on the entity level. So the sharding key is disguised as part of JPA's id. Not pretty, but works... However, it's definitely not something that I could promote to coworkers "Hey we should use this cool sharding tool, and it works with JPA only if you carefully configure it"
   > 
   > It would be great if you could share an example!
   
   ```
   @Embeddable
   @Data
   public class CompositeId implements Serializable {
       private Long id; // pk
       private String accountId; // sharding key
   }
   ```
   
   Then you can do findByCompositeIdAccountId.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] sabz90 commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
sabz90 commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-714259864


   > There is indeed a workaround - Embed the primary key and sharding key on the entity level. So the sharding key is disguised as part of JPA's id. Not pretty, but works... However, it's definitely not something that I could promote to coworkers "Hey we should use this cool sharding tool, and it works with JPA only if you carefully configure it"
   
   It would be great if you could share an example!


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero edited a comment on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
tristaZero edited a comment on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-705952634


   @sabz90 Are you going to update the sharding key of logic table? FYI, If you updated the value of sharding key, it would be possible to move this row to another table or db.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] qiuxiaotong2021 edited a comment on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
qiuxiaotong2021 edited a comment on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-914277294


   > @strongduanmu Nice!
   > Therefore, guys, another solution for this issue is to try 5.0.0-alpha. :)
   
   Hi @tristaZero , Nice!  
   Has the problem been resolved in the latest version? Or, tell me what solutions are there. After all, there are many people using spring boot JPA framework, which is not like mybatis or native jdbc orm frameworks.
   
   thanks.


-- 
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] heqiao commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
heqiao commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-716296721


   Thanks for the detailed response with a solution. @tristaZero 
   
   That's exactly what was happening. When `updatable = false` is being used, the `where clause` does not contain `shardingKey=xx` and will end up with all shards updating.
   
   Additionally, the `where clause` only contains `pk =yy` no matter `updatable = false` is being used or not. 
   
   The logic in the third paragraph makes a lot sense to me. Just want to make sure the sharding key will be included in `where clause` in the PASS cases. 


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] strongduanmu commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-752328207


   Closed because there was no reply.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] heqiao commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
heqiao commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-714273218


   > > Actually.... after a second read through of the above conversation, Trista's suggestion makes more sense. The set clause should not have sharding key. So the sharding key should not be updatable. And this solves the problem.
   > > `@Column(name = "xxx", updatable = false)`
   > > I think I need a Rubber Duck.
   > 
   > But this will execute the update query in all the shards :) Which is not optimal.
   > So even if the sharding column appears in the SET clause, the value may not have really changed... just that the field appears in SET clause.
   > 
   > Maybe there can be some annotation from sharding-sphere or some flag by which we can suppress that exception from SS because it's much more complex to explicitly include the sharding column in the where clause, especially when there's @Version involved.
   
   ah that's right. Thought I found a solution :( 
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] heqiao commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
heqiao commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-714247433


   There is indeed a workaround - Embed the primary key and sharding key on the entity level. So the sharding key is disguised as part of JPA's id. Not pretty, but works... However, it's definitely not something that I could promote to coworkers "Hey we should use this cool sharding tool, and it works with JPA only if you carefully configure it"


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-707482349


    The query does not change the Sharding key of the table. If that value does not appear in SET statement
   
   > update ACCOUNT_INFO set name=??, account_id=??, zip=??, version=?? where id = ?? and version = ??
   
   Sorry? `account_id` is a sharding key and in set clause, isn't it?
   
   
   
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] lMasterSparkl commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
lMasterSparkl commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-1067909193


   
   > > So a safer option would be to define an Annotation, something like "@ForceWhereClause" which should then indicate to sharding-sphere that it has to use the value from SET clause and either use that to figure out which is the target shard, or put in a where clause along in the final statement and let things happen naturally.
   > 
   > @sabz90 I think adding annotations is a good idea, but I think it is more appropriate for hibernate to provide this annotation. Users can freely control which fields are added to the `WHERE` clause and which fields are added to the `SET` clause through hibernate annotations.
    
   @tristaZero @strongduanmu @heqiao @sabz90 @qiuxiaotong2021 
   hey guys I have read all this issue's comments and  think it's necessary to reopen this issue .
   ### First 
   I think the comment I have quote is not the final reply that   
   
   > more appropriate for hibernate to provide this annotation
   
     
   and it doesn't solution the problem.
   ### Second 
   let me example:
   table AAA use 'id' as primary key and use 'did' as sharding key .
   now I need to edit some columns from backstage, I think it's a very easy and universal function, but wow it says **'Can not update sharding key'** and don't have Elegant solutions,  now I have to judge every column and use jpa‘s nativeQuery to update columns .
   we use did to distinguish different user so it can be the same.
   ### Final 
   let me guess the question I have figure out when I have debug, 
   ![shardingsphereDebug](https://user-images.githubusercontent.com/24791147/158369713-0216adb9-5334-4b88-8ffe-39b8531d889e.png)
   in this pic shardingValue is empty and I deep in
   ![shardingSpheregetShardingValue](https://user-images.githubusercontent.com/24791147/158369683-8c27eb7a-d7d4-4f5d-b3e5-7cb70a4d3fc6.png)
   in this pic shows shardingColumn is 'did' but in Evaluate I excute column.getIdentifier().getValue() and it return 'id' so i think it just consider when shardingColumn is primary key and value equals and then pass but not contain when shardingKey is not primary key's case.
   my english is not good but I'd like to discuss this problem. 
   


-- 
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] lMasterSparkl commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
lMasterSparkl commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-1074955190


   > @lMasterSparkl Sorry, I'm not very familiar with JPA, this may require you to study how JPA is used. Looking forward to your good news.
   
   @strongduanmu @heqiao @sabz90 @qiuxiaotong2021
   now I used interceptor to changed update sql and add sharding column in  it here is the demo
   ```
   import lombok.extern.slf4j.Slf4j;
   import org.apache.commons.lang3.StringUtils;
   import org.hibernate.EmptyInterceptor;
   import java.util.HashMap;
   import java.util.Map;
   @Slf4j
   public class AutoAddDidInterceptor extends EmptyInterceptor {
   
       public static ThreadLocal<Map<String, String>> myTable = new ThreadLocal<>();
   
       public static void setInterceptorDid(String did){
           Map<String, String> map = new HashMap<>();
           map.put("did_update", did);
       }
       @Override
       public String onPrepareStatement(String sql) {
           log.debug("sql interceptor worked" );
           Map<String, String> map = myTable.get();
           if (map == null) {
               return sql;
           }
           String did = map.get("did_update");
           if (StringUtils.isEmpty(did) ) {
               return sql;
           }
           //judge update sql
           if(sql.startsWith("update")){
               String[] wheres = sql.split("where");
               StringBuffer stringBuffer = new StringBuffer();
               stringBuffer.append(wheres[0]).append(" where did = '"+did+"' and ").append(wheres[1]);
               log.warn("sql has been modify and now is {}",stringBuffer.toString());
               //clean threadLocal
               myTable.remove();
               return stringBuffer.toString();
           }else{
               return sql;
           }
       }
   
   }
   ```
   and config the interceptor in config file I'm use properties
   
   ```
   spring.jpa.properties.hibernate.session_factory.session_scoped_interceptor=com.AutoAddDidInterceptor
   ```
   then use in business code like this
   ```
               AutoAddDidInterceptor.setInterceptorDid(post.getDid());
               postRepository.save(post);
   ```
   and in my test its already work to update data.
   
   but I have some Security question that if it might seen SQL injection problem.
   Welcome to point out the problem and give me some suggestion.
   hope to help the other programmers and save time.(~ ̄▽ ̄)~ 


-- 
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] lMasterSparkl edited a comment on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
lMasterSparkl edited a comment on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-1068794086


   > @lMasterSparkl Please try latest 5.1.0.
   @strongduanmu  it still not work, here is the error log
   ```
   Hibernate: update post set update_dt=?, did=?, base_like=?, base_pv=?, base_share=?, discuss=?, game_id=?, hot=?, images=?, is_delete=?, is_official=?, is_top=?, level=?, official_head=?, official_nick_name=?, official_title=?, post_id=?, pv=?, reply1did=?, reply1id=?, reply2did=?, reply2id=?, reply_did=?, share=?, tag=?, text=?, topic_id=?, topic_name=?, up=?, videos=? where id=?
   2022-03-16 14:43:29 JRebel: ERROR Class 'org.codehaus.groovy.ast.decompiled.AsmDecompiler' could not be processed by org.zeroturnaround.jrebel.groovy.cbp.AsmDecompilerCBP@sun.misc.Launcher$AppClassLoader@18b4aac2: org.zeroturnaround.bundled.javassist.CannotCompileException: [source error] no such field: org/codehaus/groovy/ast/decompiled/AsmDecompiler$StubCache/map
   	at org.zeroturnaround.bundled.javassist.CtBehavior.insertAfter(SourceFile:912)
   	at org.zeroturnaround.bundled.javassist.CtBehavior.insertAfter(SourceFile:825)
   	at org.zeroturnaround.javarebel.integration.support.CBPs$DirectProcessorImpl.insertAfterClinit(SourceFile:222)
   	at org.zeroturnaround.jrebel.groovy.cbp.AsmDecompilerCBP.process(AsmDecompilerCBP.java:24)
   	at org.zeroturnaround.javarebel.integration.support.JavassistClassBytecodeProcessor.process(SourceFile:136)
   	at org.zeroturnaround.javarebel.integration.support.CacheAwareJavassistClassBytecodeProcessor.process(SourceFile:34)
   	at org.zeroturnaround.javarebel.integration.support.JavassistClassBytecodeProcessor.process(SourceFile:82)
   	at com.zeroturnaround.javarebel.aad.a(SourceFile:383)
   	at com.zeroturnaround.javarebel.aad.a(SourceFile:310)
   	at com.zeroturnaround.javarebel.SDKIntegrationImpl.runBytecodeProcessors(SourceFile:41)
   	at com.zeroturnaround.javarebel.xd.transform(SourceFile:132)
   	at java.lang.ClassLoader.defineClass(ClassLoader.java:43009)
   	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
   	at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
   	at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
   	at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
   	at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
   	at java.security.AccessController.doPrivileged(Native Method)
   	at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
   	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
   	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
   	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
   	at org.codehaus.groovy.control.ClassNodeResolver.findDecompiled(ClassNodeResolver.java:255)
   	at org.codehaus.groovy.control.ClassNodeResolver.tryAsLoaderClassOrScript(ClassNodeResolver.java:193)
   	at org.codehaus.groovy.control.ClassNodeResolver.findClassNode(ClassNodeResolver.java:175)
   	at org.codehaus.groovy.control.ClassNodeResolver.resolveName(ClassNodeResolver.java:129)
   	at org.codehaus.groovy.control.ResolveVisitor.resolveToOuter(ResolveVisitor.java:770)
   	at org.codehaus.groovy.control.ResolveVisitor.resolve(ResolveVisitor.java:418)
   	at org.codehaus.groovy.control.ResolveVisitor.resolveFromDefaultImports(ResolveVisitor.java:567)
   	at org.codehaus.groovy.control.ResolveVisitor.resolveFromDefaultImports(ResolveVisitor.java:536)
   	at org.codehaus.groovy.control.ResolveVisitor.resolve(ResolveVisitor.java:417)
   	at org.codehaus.groovy.control.ResolveVisitor.resolve(ResolveVisitor.java:380)
   	at org.codehaus.groovy.control.ResolveVisitor.transformVariableExpression(ResolveVisitor.java:1030)
   	at org.codehaus.groovy.control.ResolveVisitor.transform(ResolveVisitor.java:789)
   	at org.codehaus.groovy.control.ResolveVisitor.transformMethodCallExpression(ResolveVisitor.java:1149)
   	at org.codehaus.groovy.control.ResolveVisitor.transform(ResolveVisitor.java:797)
   	at org.codehaus.groovy.control.ResolveVisitor.transformBinaryExpression(ResolveVisitor.java:1055)
   	at org.codehaus.groovy.control.ResolveVisitor.transform(ResolveVisitor.java:795)
   	at org.codehaus.groovy.ast.expr.Expression.transformExpressions(Expression.java:49)
   	at org.codehaus.groovy.ast.expr.GStringExpression.transformExpression(GStringExpression.java:61)
   	at org.codehaus.groovy.control.ResolveVisitor.transform(ResolveVisitor.java:806)
   	at org.codehaus.groovy.ast.ClassCodeExpressionTransformer.visitExpressionStatement(ClassCodeExpressionTransformer.java:108)
   	at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:41)
   	at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:86)
   	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:168)
   	at org.codehaus.groovy.control.ResolveVisitor.visitBlockStatement(ResolveVisitor.java:1419)
   	at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:70)
   	at org.codehaus.groovy.control.ResolveVisitor.transformClosureExpression(ResolveVisitor.java:1125)
   	at org.codehaus.groovy.control.ResolveVisitor.transform(ResolveVisitor.java:799)
   	at org.codehaus.groovy.ast.ClassCodeExpressionTransformer.visitExpressionStatement(ClassCodeExpressionTransformer.java:108)
   	at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:41)
   	at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:86)
   	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:168)
   	at org.codehaus.groovy.control.ResolveVisitor.visitBlockStatement(ResolveVisitor.java:1419)
   	at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:70)
   	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:142)
   	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:115)
   	at org.codehaus.groovy.ast.ClassCodeExpressionTransformer.visitConstructorOrMethod(ClassCodeExpressionTransformer.java:66)
   	at org.codehaus.groovy.control.ResolveVisitor.visitConstructorOrMethod(ResolveVisitor.java:303)
   	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:110)
   	at org.codehaus.groovy.control.ResolveVisitor.visitMethod(ResolveVisitor.java:273)
   	at org.codehaus.groovy.ast.ClassNode.visitMethods(ClassNode.java:1135)
   	at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1128)
   	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:52)
   	at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1363)
   	at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:263)
   	at org.codehaus.groovy.control.CompilationUnit.lambda$addPhaseOperations$3(CompilationUnit.java:204)
   	at org.codehaus.groovy.control.CompilationUnit$ISourceUnitOperation.doPhaseOperation(CompilationUnit.java:859)
   	at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:654)
   	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:628)
   	at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:368)
   	at groovy.lang.GroovyClassLoader.lambda$parseClass$2(GroovyClassLoader.java:311)
   	at org.codehaus.groovy.runtime.memoize.StampedCommonCache.compute(StampedCommonCache.java:163)
   	at org.codehaus.groovy.runtime.memoize.StampedCommonCache.getAndPut(StampedCommonCache.java:154)
   	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:309)
   	at groovy.lang.GroovyShell.parseClass(GroovyShell.java:543)
   	at groovy.lang.GroovyShell.parse(GroovyShell.java:556)
   	at groovy.lang.GroovyShell.parse(GroovyShell.java:610)
   	at groovy.lang.GroovyShell.parse(GroovyShell.java:596)
   	at groovy.lang.GroovyShell.parse(GroovyShell.java:605)
   	at org.apache.shardingsphere.sharding.support.InlineExpressionParser.evaluate(InlineExpressionParser.java:109)
   	at org.apache.shardingsphere.sharding.support.InlineExpressionParser.evaluateClosure(InlineExpressionParser.java:86)
   	at org.apache.shardingsphere.sharding.algorithm.sharding.inline.InlineShardingAlgorithm.createClosure(InlineShardingAlgorithm.java:84)
   	at org.apache.shardingsphere.sharding.algorithm.sharding.inline.InlineShardingAlgorithm.doSharding(InlineShardingAlgorithm.java:70)
   	at org.apache.shardingsphere.sharding.route.strategy.type.standard.StandardShardingStrategy.doSharding(StandardShardingStrategy.java:68)
   	at org.apache.shardingsphere.sharding.route.strategy.type.standard.StandardShardingStrategy.doSharding(StandardShardingStrategy.java:57)
   	at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.routeDataSources(ShardingStandardRoutingEngine.java:206)
   	at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.route0(ShardingStandardRoutingEngine.java:194)
   	at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.routeByShardingConditionsWithCondition(ShardingStandardRoutingEngine.java:117)
   	at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.routeByShardingConditions(ShardingStandardRoutingEngine.java:110)
   	at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.getDataNodes(ShardingStandardRoutingEngine.java:87)
   	at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.route(ShardingStandardRoutingEngine.java:69)
   	at org.apache.shardingsphere.sharding.route.engine.validator.dml.impl.ShardingUpdateStatementValidator.lambda$postValidate$0(ShardingUpdateStatementValidator.java:52)
   	at java.util.Optional.map(Optional.java:215)
   	at org.apache.shardingsphere.sharding.route.engine.validator.dml.impl.ShardingUpdateStatementValidator.postValidate(ShardingUpdateStatementValidator.java:52)
   	at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.lambda$createRouteContext$1(ShardingSQLRouter.java:57)
   	at java.util.Optional.ifPresent(Optional.java:159)
   	at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext(ShardingSQLRouter.java:57)
   	at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext(ShardingSQLRouter.java:44)
   	at org.apache.shardingsphere.infra.route.engine.impl.PartialSQLRouteExecutor.route(PartialSQLRouteExecutor.java:73)
   	at org.apache.shardingsphere.infra.route.engine.SQLRouteEngine.route(SQLRouteEngine.java:53)
   	at org.apache.shardingsphere.infra.context.kernel.KernelProcessor.route(KernelProcessor.java:54)
   	at org.apache.shardingsphere.infra.context.kernel.KernelProcessor.generateExecutionContext(KernelProcessor.java:46)
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.createExecutionContext(ShardingSpherePreparedStatement.java:431)
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.addBatch(ShardingSpherePreparedStatement.java:500)
   	at org.hibernate.engine.jdbc.batch.internal.BatchingBatch.addToBatch(BatchingBatch.java:78)
   	at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3445)
   	at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:3312)
   	at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3726)
   	at org.hibernate.action.internal.EntityUpdateAction.execute(EntityUpdateAction.java:201)
   	at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:604)
   	at org.hibernate.engine.spi.ActionQueue.lambda$executeActions$1(ActionQueue.java:478)
   	at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
   	at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:475)
   	at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:348)
   	at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:40)
   	at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:102)
   	at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1363)
   	at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:454)
   	at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:3213)
   	at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2381)
   	at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:447)
   	at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:183)
   	at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$300(JdbcResourceLocalTransactionCoordinatorImpl.java:40)
   	at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:281)
   	at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:101)
   	at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:534)
   	at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:743)
   	at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:711)
   	at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:633)
   	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:386)
   	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118)
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
   	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139)
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
   	at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:178)
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
   	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95)
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
   	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
   	at com.sun.proxy.$Proxy356.save(Unknown Source)
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.lang.reflect.Method.invoke(Method.java:498)
   	at org.zeroturnaround.jrebel.integration.springdata.RepositoryReloadingProxyFactoryBuilder$ReloadingMethodHandler.invoke(RepositoryReloadingProxyFactoryBuilder.java:80)
   	at com.sun.proxy.$Proxy356.save(Unknown Source)
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.lang.reflect.Method.invoke(Method.java:498)
   	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
   	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:205)
   	at com.sun.proxy.$Proxy294.save(Unknown Source)
   	at com.gameley.services.user.service.impl.PostAdminServiceImpl.save(PostAdminServiceImpl.java:160)
   	at com.gameley.services.user.kafka.BbsConsumer.admin2userLottery(BbsConsumer.java:36)
   	at com.gameley.services.user.kafka.BbsConsumer$$FastClassBySpringCGLIB$$1.invoke(<generated>)
   	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
   	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771)
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
   	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
   	at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:88)
   	at com.gameley.services.user.aop.RedissonAop.doAround(RedissonAop.java:76)
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.lang.reflect.Method.invoke(Method.java:498)
   	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644)
   	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:633)
   	at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175)
   	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
   	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95)
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
   	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
   	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691)
   	at com.gameley.services.user.kafka.BbsConsumer$$EnhancerBySpringCGLIB$$1.admin2userLottery(<generated>)
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.lang.reflect.Method.invoke(Method.java:498)
   	at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:171)
   	at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:120)
   	at org.springframework.kafka.listener.adapter.HandlerAdapter.invoke(HandlerAdapter.java:48)
   	at org.springframework.kafka.listener.adapter.MessagingMessageListenerAdapter.invokeHandler(MessagingMessageListenerAdapter.java:329)
   	at org.springframework.kafka.listener.adapter.RecordMessagingMessageListenerAdapter.onMessage(RecordMessagingMessageListenerAdapter.java:86)
   	at org.springframework.kafka.listener.adapter.RecordMessagingMessageListenerAdapter.onMessage(RecordMessagingMessageListenerAdapter.java:51)
   	at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.doInvokeOnMessage(KafkaMessageListenerContainer.java:1880)
   	at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.invokeOnMessage(KafkaMessageListenerContainer.java:1862)
   	at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.doInvokeRecordListener(KafkaMessageListenerContainer.java:1799)
   	at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.doInvokeWithRecords(KafkaMessageListenerContainer.java:1739)
   	at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.invokeRecordListener(KafkaMessageListenerContainer.java:1636)
   	at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.invokeListener(KafkaMessageListenerContainer.java:1366)
   	at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.pollAndInvoke(KafkaMessageListenerContainer.java:1082)
   	at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.run(KafkaMessageListenerContainer.java:990)
   	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
   	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
   	at java.lang.Thread.run(Thread.java:748)
   Caused by: compile error: no such field: org/codehaus/groovy/ast/decompiled/AsmDecompiler$StubCache/map
   	at org.zeroturnaround.bundled.javassist.compiler.MemberResolver.lookupFieldByJvmName2(SourceFile:288)
   	at org.zeroturnaround.bundled.javassist.compiler.TypeChecker.fieldAccess2(SourceFile:941)
   	at org.zeroturnaround.bundled.javassist.compiler.TypeChecker.fieldAccess(SourceFile:898)
   	at org.zeroturnaround.bundled.javassist.compiler.TypeChecker.atFieldRead(SourceFile:831)
   	at org.zeroturnaround.bundled.javassist.compiler.TypeChecker.atExpr(SourceFile:605)
   	at org.zeroturnaround.bundled.javassist.compiler.ast.Expr.accept(SourceFile:71)
   	at org.zeroturnaround.bundled.javassist.compiler.JvstTypeChecker.atMethodArgs(SourceFile:235)
   	at org.zeroturnaround.bundled.javassist.compiler.TypeChecker.atMethodCallCore(SourceFile:763)
   	at org.zeroturnaround.bundled.javassist.compiler.TypeChecker.atNewExpr(SourceFile:171)
   	at org.zeroturnaround.bundled.javassist.compiler.ast.NewExpr.accept(SourceFile:75)
   	at org.zeroturnaround.bundled.javassist.compiler.TypeChecker.atFieldAssign(SourceFile:301)
   	at org.zeroturnaround.bundled.javassist.compiler.JvstTypeChecker.atFieldAssign(SourceFile:95)
   	at org.zeroturnaround.bundled.javassist.compiler.TypeChecker.atAssignExpr(SourceFile:255)
   	at org.zeroturnaround.bundled.javassist.compiler.ast.AssignExpr.accept(SourceFile:43)
   	at org.zeroturnaround.bundled.javassist.compiler.CodeGen.doTypeCheck(SourceFile:266)
   	at org.zeroturnaround.bundled.javassist.compiler.CodeGen.atStmnt(SourceFile:362)
   	at org.zeroturnaround.bundled.javassist.compiler.ast.Stmnt.accept(SourceFile:53)
   	at org.zeroturnaround.bundled.javassist.compiler.Javac.compileStmnt(SourceFile:578)
   	at org.zeroturnaround.bundled.javassist.CtBehavior.insertAfterAdvice(SourceFile:927)
   	at org.zeroturnaround.bundled.javassist.CtBehavior.insertAfter(SourceFile:885)
   	... 197 more
   
   
   Caused by: org.apache.shardingsphere.infra.exception.ShardingSphereException: Can not update sharding key since the updated value will change post's data nodes.
   	at org.apache.shardingsphere.sharding.route.engine.validator.dml.impl.ShardingUpdateStatementValidator.postValidate(ShardingUpdateStatementValidator.java:54)
   	at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.lambda$createRouteContext$1(ShardingSQLRouter.java:57)
   	at java.util.Optional.ifPresent(Optional.java:159)
   	at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext(ShardingSQLRouter.java:57)
   	at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext(ShardingSQLRouter.java:44)
   	at org.apache.shardingsphere.infra.route.engine.impl.PartialSQLRouteExecutor.route(PartialSQLRouteExecutor.java:73)
   	at org.apache.shardingsphere.infra.route.engine.SQLRouteEngine.route(SQLRouteEngine.java:53)
   	at org.apache.shardingsphere.infra.context.kernel.KernelProcessor.route(KernelProcessor.java:54)
   	at org.apache.shardingsphere.infra.context.kernel.KernelProcessor.generateExecutionContext(KernelProcessor.java:46)
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.createExecutionContext(ShardingSpherePreparedStatement.java:431)
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.addBatch(ShardingSpherePreparedStatement.java:500)
   	at org.hibernate.engine.jdbc.batch.internal.BatchingBatch.addToBatch(BatchingBatch.java:78)
   	at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3445)
   	at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:3312)
   	at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3726)
   	at org.hibernate.action.internal.EntityUpdateAction.execute(EntityUpdateAction.java:201)
   	at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:604)
   	at org.hibernate.engine.spi.ActionQueue.lambda$executeActions$1(ActionQueue.java:478)
   	at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
   	at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:475)
   	at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:348)
   	at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:40)
   	at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:102)
   	at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1363)
   	at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:454)
   	at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:3213)
   	at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2381)
   	at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:447)
   	at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:183)
   	at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$300(JdbcResourceLocalTransactionCoordinatorImpl.java:40)
   	at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:281)
   	at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:101)
   	... 72 more
   
   ```
   


-- 
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] lMasterSparkl commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
lMasterSparkl commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-1068794086


   > @lMasterSparkl Please try latest 5.1.0.
   it still not work, here is the error log
   ```
   Hibernate: update post set update_dt=?, did=?, base_like=?, base_pv=?, base_share=?, discuss=?, game_id=?, hot=?, images=?, is_delete=?, is_official=?, is_top=?, level=?, official_head=?, official_nick_name=?, official_title=?, post_id=?, pv=?, reply1did=?, reply1id=?, reply2did=?, reply2id=?, reply_did=?, share=?, tag=?, text=?, topic_id=?, topic_name=?, up=?, videos=? where id=?
   2022-03-16 14:43:29 JRebel: ERROR Class 'org.codehaus.groovy.ast.decompiled.AsmDecompiler' could not be processed by org.zeroturnaround.jrebel.groovy.cbp.AsmDecompilerCBP@sun.misc.Launcher$AppClassLoader@18b4aac2: org.zeroturnaround.bundled.javassist.CannotCompileException: [source error] no such field: org/codehaus/groovy/ast/decompiled/AsmDecompiler$StubCache/map
   	at org.zeroturnaround.bundled.javassist.CtBehavior.insertAfter(SourceFile:912)
   	at org.zeroturnaround.bundled.javassist.CtBehavior.insertAfter(SourceFile:825)
   	at org.zeroturnaround.javarebel.integration.support.CBPs$DirectProcessorImpl.insertAfterClinit(SourceFile:222)
   	at org.zeroturnaround.jrebel.groovy.cbp.AsmDecompilerCBP.process(AsmDecompilerCBP.java:24)
   	at org.zeroturnaround.javarebel.integration.support.JavassistClassBytecodeProcessor.process(SourceFile:136)
   	at org.zeroturnaround.javarebel.integration.support.CacheAwareJavassistClassBytecodeProcessor.process(SourceFile:34)
   	at org.zeroturnaround.javarebel.integration.support.JavassistClassBytecodeProcessor.process(SourceFile:82)
   	at com.zeroturnaround.javarebel.aad.a(SourceFile:383)
   	at com.zeroturnaround.javarebel.aad.a(SourceFile:310)
   	at com.zeroturnaround.javarebel.SDKIntegrationImpl.runBytecodeProcessors(SourceFile:41)
   	at com.zeroturnaround.javarebel.xd.transform(SourceFile:132)
   	at java.lang.ClassLoader.defineClass(ClassLoader.java:43009)
   	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
   	at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
   	at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
   	at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
   	at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
   	at java.security.AccessController.doPrivileged(Native Method)
   	at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
   	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
   	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
   	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
   	at org.codehaus.groovy.control.ClassNodeResolver.findDecompiled(ClassNodeResolver.java:255)
   	at org.codehaus.groovy.control.ClassNodeResolver.tryAsLoaderClassOrScript(ClassNodeResolver.java:193)
   	at org.codehaus.groovy.control.ClassNodeResolver.findClassNode(ClassNodeResolver.java:175)
   	at org.codehaus.groovy.control.ClassNodeResolver.resolveName(ClassNodeResolver.java:129)
   	at org.codehaus.groovy.control.ResolveVisitor.resolveToOuter(ResolveVisitor.java:770)
   	at org.codehaus.groovy.control.ResolveVisitor.resolve(ResolveVisitor.java:418)
   	at org.codehaus.groovy.control.ResolveVisitor.resolveFromDefaultImports(ResolveVisitor.java:567)
   	at org.codehaus.groovy.control.ResolveVisitor.resolveFromDefaultImports(ResolveVisitor.java:536)
   	at org.codehaus.groovy.control.ResolveVisitor.resolve(ResolveVisitor.java:417)
   	at org.codehaus.groovy.control.ResolveVisitor.resolve(ResolveVisitor.java:380)
   	at org.codehaus.groovy.control.ResolveVisitor.transformVariableExpression(ResolveVisitor.java:1030)
   	at org.codehaus.groovy.control.ResolveVisitor.transform(ResolveVisitor.java:789)
   	at org.codehaus.groovy.control.ResolveVisitor.transformMethodCallExpression(ResolveVisitor.java:1149)
   	at org.codehaus.groovy.control.ResolveVisitor.transform(ResolveVisitor.java:797)
   	at org.codehaus.groovy.control.ResolveVisitor.transformBinaryExpression(ResolveVisitor.java:1055)
   	at org.codehaus.groovy.control.ResolveVisitor.transform(ResolveVisitor.java:795)
   	at org.codehaus.groovy.ast.expr.Expression.transformExpressions(Expression.java:49)
   	at org.codehaus.groovy.ast.expr.GStringExpression.transformExpression(GStringExpression.java:61)
   	at org.codehaus.groovy.control.ResolveVisitor.transform(ResolveVisitor.java:806)
   	at org.codehaus.groovy.ast.ClassCodeExpressionTransformer.visitExpressionStatement(ClassCodeExpressionTransformer.java:108)
   	at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:41)
   	at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:86)
   	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:168)
   	at org.codehaus.groovy.control.ResolveVisitor.visitBlockStatement(ResolveVisitor.java:1419)
   	at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:70)
   	at org.codehaus.groovy.control.ResolveVisitor.transformClosureExpression(ResolveVisitor.java:1125)
   	at org.codehaus.groovy.control.ResolveVisitor.transform(ResolveVisitor.java:799)
   	at org.codehaus.groovy.ast.ClassCodeExpressionTransformer.visitExpressionStatement(ClassCodeExpressionTransformer.java:108)
   	at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:41)
   	at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:86)
   	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:168)
   	at org.codehaus.groovy.control.ResolveVisitor.visitBlockStatement(ResolveVisitor.java:1419)
   	at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:70)
   	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:142)
   	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:115)
   	at org.codehaus.groovy.ast.ClassCodeExpressionTransformer.visitConstructorOrMethod(ClassCodeExpressionTransformer.java:66)
   	at org.codehaus.groovy.control.ResolveVisitor.visitConstructorOrMethod(ResolveVisitor.java:303)
   	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:110)
   	at org.codehaus.groovy.control.ResolveVisitor.visitMethod(ResolveVisitor.java:273)
   	at org.codehaus.groovy.ast.ClassNode.visitMethods(ClassNode.java:1135)
   	at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1128)
   	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:52)
   	at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1363)
   	at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:263)
   	at org.codehaus.groovy.control.CompilationUnit.lambda$addPhaseOperations$3(CompilationUnit.java:204)
   	at org.codehaus.groovy.control.CompilationUnit$ISourceUnitOperation.doPhaseOperation(CompilationUnit.java:859)
   	at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:654)
   	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:628)
   	at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:368)
   	at groovy.lang.GroovyClassLoader.lambda$parseClass$2(GroovyClassLoader.java:311)
   	at org.codehaus.groovy.runtime.memoize.StampedCommonCache.compute(StampedCommonCache.java:163)
   	at org.codehaus.groovy.runtime.memoize.StampedCommonCache.getAndPut(StampedCommonCache.java:154)
   	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:309)
   	at groovy.lang.GroovyShell.parseClass(GroovyShell.java:543)
   	at groovy.lang.GroovyShell.parse(GroovyShell.java:556)
   	at groovy.lang.GroovyShell.parse(GroovyShell.java:610)
   	at groovy.lang.GroovyShell.parse(GroovyShell.java:596)
   	at groovy.lang.GroovyShell.parse(GroovyShell.java:605)
   	at org.apache.shardingsphere.sharding.support.InlineExpressionParser.evaluate(InlineExpressionParser.java:109)
   	at org.apache.shardingsphere.sharding.support.InlineExpressionParser.evaluateClosure(InlineExpressionParser.java:86)
   	at org.apache.shardingsphere.sharding.algorithm.sharding.inline.InlineShardingAlgorithm.createClosure(InlineShardingAlgorithm.java:84)
   	at org.apache.shardingsphere.sharding.algorithm.sharding.inline.InlineShardingAlgorithm.doSharding(InlineShardingAlgorithm.java:70)
   	at org.apache.shardingsphere.sharding.route.strategy.type.standard.StandardShardingStrategy.doSharding(StandardShardingStrategy.java:68)
   	at org.apache.shardingsphere.sharding.route.strategy.type.standard.StandardShardingStrategy.doSharding(StandardShardingStrategy.java:57)
   	at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.routeDataSources(ShardingStandardRoutingEngine.java:206)
   	at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.route0(ShardingStandardRoutingEngine.java:194)
   	at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.routeByShardingConditionsWithCondition(ShardingStandardRoutingEngine.java:117)
   	at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.routeByShardingConditions(ShardingStandardRoutingEngine.java:110)
   	at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.getDataNodes(ShardingStandardRoutingEngine.java:87)
   	at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.route(ShardingStandardRoutingEngine.java:69)
   	at org.apache.shardingsphere.sharding.route.engine.validator.dml.impl.ShardingUpdateStatementValidator.lambda$postValidate$0(ShardingUpdateStatementValidator.java:52)
   	at java.util.Optional.map(Optional.java:215)
   	at org.apache.shardingsphere.sharding.route.engine.validator.dml.impl.ShardingUpdateStatementValidator.postValidate(ShardingUpdateStatementValidator.java:52)
   	at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.lambda$createRouteContext$1(ShardingSQLRouter.java:57)
   	at java.util.Optional.ifPresent(Optional.java:159)
   	at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext(ShardingSQLRouter.java:57)
   	at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext(ShardingSQLRouter.java:44)
   	at org.apache.shardingsphere.infra.route.engine.impl.PartialSQLRouteExecutor.route(PartialSQLRouteExecutor.java:73)
   	at org.apache.shardingsphere.infra.route.engine.SQLRouteEngine.route(SQLRouteEngine.java:53)
   	at org.apache.shardingsphere.infra.context.kernel.KernelProcessor.route(KernelProcessor.java:54)
   	at org.apache.shardingsphere.infra.context.kernel.KernelProcessor.generateExecutionContext(KernelProcessor.java:46)
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.createExecutionContext(ShardingSpherePreparedStatement.java:431)
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.addBatch(ShardingSpherePreparedStatement.java:500)
   	at org.hibernate.engine.jdbc.batch.internal.BatchingBatch.addToBatch(BatchingBatch.java:78)
   	at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3445)
   	at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:3312)
   	at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3726)
   	at org.hibernate.action.internal.EntityUpdateAction.execute(EntityUpdateAction.java:201)
   	at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:604)
   	at org.hibernate.engine.spi.ActionQueue.lambda$executeActions$1(ActionQueue.java:478)
   	at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
   	at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:475)
   	at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:348)
   	at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:40)
   	at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:102)
   	at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1363)
   	at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:454)
   	at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:3213)
   	at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2381)
   	at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:447)
   	at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:183)
   	at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$300(JdbcResourceLocalTransactionCoordinatorImpl.java:40)
   	at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:281)
   	at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:101)
   	at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:534)
   	at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:743)
   	at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:711)
   	at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:633)
   	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:386)
   	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118)
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
   	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139)
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
   	at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:178)
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
   	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95)
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
   	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
   	at com.sun.proxy.$Proxy356.save(Unknown Source)
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.lang.reflect.Method.invoke(Method.java:498)
   	at org.zeroturnaround.jrebel.integration.springdata.RepositoryReloadingProxyFactoryBuilder$ReloadingMethodHandler.invoke(RepositoryReloadingProxyFactoryBuilder.java:80)
   	at com.sun.proxy.$Proxy356.save(Unknown Source)
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.lang.reflect.Method.invoke(Method.java:498)
   	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
   	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:205)
   	at com.sun.proxy.$Proxy294.save(Unknown Source)
   	at com.gameley.services.user.service.impl.PostAdminServiceImpl.save(PostAdminServiceImpl.java:160)
   	at com.gameley.services.user.kafka.BbsConsumer.admin2userLottery(BbsConsumer.java:36)
   	at com.gameley.services.user.kafka.BbsConsumer$$FastClassBySpringCGLIB$$1.invoke(<generated>)
   	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
   	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771)
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
   	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
   	at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:88)
   	at com.gameley.services.user.aop.RedissonAop.doAround(RedissonAop.java:76)
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.lang.reflect.Method.invoke(Method.java:498)
   	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644)
   	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:633)
   	at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175)
   	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
   	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95)
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
   	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
   	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691)
   	at com.gameley.services.user.kafka.BbsConsumer$$EnhancerBySpringCGLIB$$1.admin2userLottery(<generated>)
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.lang.reflect.Method.invoke(Method.java:498)
   	at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:171)
   	at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:120)
   	at org.springframework.kafka.listener.adapter.HandlerAdapter.invoke(HandlerAdapter.java:48)
   	at org.springframework.kafka.listener.adapter.MessagingMessageListenerAdapter.invokeHandler(MessagingMessageListenerAdapter.java:329)
   	at org.springframework.kafka.listener.adapter.RecordMessagingMessageListenerAdapter.onMessage(RecordMessagingMessageListenerAdapter.java:86)
   	at org.springframework.kafka.listener.adapter.RecordMessagingMessageListenerAdapter.onMessage(RecordMessagingMessageListenerAdapter.java:51)
   	at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.doInvokeOnMessage(KafkaMessageListenerContainer.java:1880)
   	at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.invokeOnMessage(KafkaMessageListenerContainer.java:1862)
   	at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.doInvokeRecordListener(KafkaMessageListenerContainer.java:1799)
   	at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.doInvokeWithRecords(KafkaMessageListenerContainer.java:1739)
   	at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.invokeRecordListener(KafkaMessageListenerContainer.java:1636)
   	at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.invokeListener(KafkaMessageListenerContainer.java:1366)
   	at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.pollAndInvoke(KafkaMessageListenerContainer.java:1082)
   	at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.run(KafkaMessageListenerContainer.java:990)
   	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
   	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
   	at java.lang.Thread.run(Thread.java:748)
   Caused by: compile error: no such field: org/codehaus/groovy/ast/decompiled/AsmDecompiler$StubCache/map
   	at org.zeroturnaround.bundled.javassist.compiler.MemberResolver.lookupFieldByJvmName2(SourceFile:288)
   	at org.zeroturnaround.bundled.javassist.compiler.TypeChecker.fieldAccess2(SourceFile:941)
   	at org.zeroturnaround.bundled.javassist.compiler.TypeChecker.fieldAccess(SourceFile:898)
   	at org.zeroturnaround.bundled.javassist.compiler.TypeChecker.atFieldRead(SourceFile:831)
   	at org.zeroturnaround.bundled.javassist.compiler.TypeChecker.atExpr(SourceFile:605)
   	at org.zeroturnaround.bundled.javassist.compiler.ast.Expr.accept(SourceFile:71)
   	at org.zeroturnaround.bundled.javassist.compiler.JvstTypeChecker.atMethodArgs(SourceFile:235)
   	at org.zeroturnaround.bundled.javassist.compiler.TypeChecker.atMethodCallCore(SourceFile:763)
   	at org.zeroturnaround.bundled.javassist.compiler.TypeChecker.atNewExpr(SourceFile:171)
   	at org.zeroturnaround.bundled.javassist.compiler.ast.NewExpr.accept(SourceFile:75)
   	at org.zeroturnaround.bundled.javassist.compiler.TypeChecker.atFieldAssign(SourceFile:301)
   	at org.zeroturnaround.bundled.javassist.compiler.JvstTypeChecker.atFieldAssign(SourceFile:95)
   	at org.zeroturnaround.bundled.javassist.compiler.TypeChecker.atAssignExpr(SourceFile:255)
   	at org.zeroturnaround.bundled.javassist.compiler.ast.AssignExpr.accept(SourceFile:43)
   	at org.zeroturnaround.bundled.javassist.compiler.CodeGen.doTypeCheck(SourceFile:266)
   	at org.zeroturnaround.bundled.javassist.compiler.CodeGen.atStmnt(SourceFile:362)
   	at org.zeroturnaround.bundled.javassist.compiler.ast.Stmnt.accept(SourceFile:53)
   	at org.zeroturnaround.bundled.javassist.compiler.Javac.compileStmnt(SourceFile:578)
   	at org.zeroturnaround.bundled.javassist.CtBehavior.insertAfterAdvice(SourceFile:927)
   	at org.zeroturnaround.bundled.javassist.CtBehavior.insertAfter(SourceFile:885)
   	... 197 more
   
   
   Caused by: org.apache.shardingsphere.infra.exception.ShardingSphereException: Can not update sharding key since the updated value will change post's data nodes.
   	at org.apache.shardingsphere.sharding.route.engine.validator.dml.impl.ShardingUpdateStatementValidator.postValidate(ShardingUpdateStatementValidator.java:54)
   	at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.lambda$createRouteContext$1(ShardingSQLRouter.java:57)
   	at java.util.Optional.ifPresent(Optional.java:159)
   	at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext(ShardingSQLRouter.java:57)
   	at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext(ShardingSQLRouter.java:44)
   	at org.apache.shardingsphere.infra.route.engine.impl.PartialSQLRouteExecutor.route(PartialSQLRouteExecutor.java:73)
   	at org.apache.shardingsphere.infra.route.engine.SQLRouteEngine.route(SQLRouteEngine.java:53)
   	at org.apache.shardingsphere.infra.context.kernel.KernelProcessor.route(KernelProcessor.java:54)
   	at org.apache.shardingsphere.infra.context.kernel.KernelProcessor.generateExecutionContext(KernelProcessor.java:46)
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.createExecutionContext(ShardingSpherePreparedStatement.java:431)
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.addBatch(ShardingSpherePreparedStatement.java:500)
   	at org.hibernate.engine.jdbc.batch.internal.BatchingBatch.addToBatch(BatchingBatch.java:78)
   	at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3445)
   	at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:3312)
   	at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3726)
   	at org.hibernate.action.internal.EntityUpdateAction.execute(EntityUpdateAction.java:201)
   	at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:604)
   	at org.hibernate.engine.spi.ActionQueue.lambda$executeActions$1(ActionQueue.java:478)
   	at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
   	at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:475)
   	at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:348)
   	at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:40)
   	at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:102)
   	at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1363)
   	at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:454)
   	at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:3213)
   	at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2381)
   	at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:447)
   	at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:183)
   	at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$300(JdbcResourceLocalTransactionCoordinatorImpl.java:40)
   	at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:281)
   	at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:101)
   	... 72 more
   
   ```
   


-- 
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] strongduanmu commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-736588951


   > Thanks for your feedback. @heqiao @sabz90
   > I read the conversation above, and gave my thinking here.
   > 
   > First, the annotation `@Column(name = "xxx", updatable = false)` seems one solution to avoid `SET shardingKey=xxx`and the exception `Can not update sharding key` accordingly.
   > 
   > Second, how to understand `But this will execute the update query in all the shards :) Which is not optimal.`?
   > Does it mean that if `@Column(name = "xxx", updatable = false)` is added, the `where clause` will not contain `shardingKey=xx`, which will cause all shards updating?
   > 
   > Third, Do you think the following improvement is reasonable and in your expectation?
   > 
   > ```java
   > if (no shardingKey in SET Clause)
   >     then PASS
   > else if (the value of shardingKey in SET Clause == the value of shardingKey in WHERE Clause)
   >     then PASS
   > else
   >     then an exception
   > ```
   
   @tristaZero @heqiao I have checked the logic in `ShardingUpdateStatementValidator`, whether it is version `4.1.1` or version `5.0.0-alpha`, it has already supported the verification logic of whether the sharding key is the same in the `SET` and `WHERE` clauses. The code is as follows:
   
   ```java
   /**
    * Sharding update statement validator.
    */
   public final class ShardingUpdateStatementValidator implements ShardingStatementValidator<UpdateStatement> {
       
       @Override
       public void validate(final ShardingRule shardingRule, final UpdateStatement sqlStatement, final List<Object> parameters) {
           String tableName = sqlStatement.getTables().iterator().next().getTableName().getIdentifier().getValue();
           for (AssignmentSegment each : sqlStatement.getSetAssignment().getAssignments()) {
               String shardingColumn = each.getColumn().getIdentifier().getValue();
               if (shardingRule.isShardingColumn(shardingColumn, tableName)) {
                   Optional<Object> shardingColumnSetAssignmentValue = getShardingColumnSetAssignmentValue(each, parameters);
                   Optional<Object> shardingValue = Optional.empty();
                   Optional<WhereSegment> whereSegmentOptional = sqlStatement.getWhere();
                   if (whereSegmentOptional.isPresent()) {
                       shardingValue = getShardingValue(whereSegmentOptional.get(), parameters, shardingColumn);
                   }
                   if (shardingColumnSetAssignmentValue.isPresent() && shardingValue.isPresent() && shardingColumnSetAssignmentValue.get().equals(shardingValue.get())) {
                       continue;
                   }
                   throw new ShardingSphereException("Can not update sharding key, logic table: [%s], column: [%s].", tableName, each);
               }
           }
       }
   }
   ```
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] heqiao commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
heqiao commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-737649233


   @sabz90 your approach is probably more sustainable. 
   
   I also found drawbacks of CompositeKey like the id won't be generated with snowflake as there is no @id annotation. 


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] heqiao commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
heqiao commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-1078683498


   Hello folks! It has been a while since I attempted to work around this issue. I kinda agreed upon that this is more a JPA enhancement rather than a shardingsphere one. 
   
   @lMasterSparkl  Thanks for sharing! I did try the same approach - creating a customized annotation, extending `EmptyInterceptor`, intercept during onPrepareStatement. However, it was hacky enough that I ended up with sticking to the CompositeId approach. The main concern was replacing " where " on sql preparing.  Although "where" is reserved, there is a chance that it's get included in the sql and I prefer not to risk it. 
   
   The CompositeId approach does work, but the code is neither pretty nor succinct. I did not investigate further, but an ideal solution IMO would be creating a property annotation and treat that property of the Entity differently, thus avoiding sql injection like replacement. This may involve more expertise in the JPA community, something that could be explored.
   
   
   
   


-- 
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] tristaZero edited a comment on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
tristaZero edited a comment on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-723738957


   > The title of the issue can be misleading.
   
   +1, however, users may locate this issue by the concrete exception info, I guess.
   Besides, as I said above, `updating sharding key` (comes with row migration) is supposed to be one of the capabilities for a perfect distributed database solution. Unfortunately, SS can not has better support for it but is moving towards it at present.
   Hence, we can solve this issue by having users add an annotation for JPA and avoid this exception by [digesting some cases](https://github.com/apache/shardingsphere/issues/7703#issuecomment-716284082) inside SS.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] kimmking commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
kimmking commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-706114796


   As @tristaZero said, sharding-key can't be update to another value cause it will change the distribution of data.
   You also can delete the old key and insert a row with new key.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] heqiao commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
heqiao commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-714243404


   @tristaZero @kimmking Please reopen this issue. I'm on the same boat with @sabz90 with same setup and same issue. I didn't attempt to update sharding key. When `update` with JPA/Hibernate, the sharding key is not included in the where clause and the error message stated `Can not update sharding key`.  Moreover, it seems all similar issues were closed without a proper solution. such as #5596 


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-705952634


   @sabz90 Are you going to update the sharding key of logic table? FYI, If you update the value of sharding key, it is possible to move this row to another table or db.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] heqiao commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
heqiao commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-736998272


   @strongduanmu Thank you for diving into it. @tristaZero My apologies that the proposed solution may not work as I originally agreed. The where clause doesn't contain the sharding key. 
   
   e.g. `update ACCOUNT_INFO set name=??, account_id=??, zip=??, version=?? where id = ??` was the generated sql with account_id being the sharding key. The `shardingValue` is empty in the code @strongduanmu posted (ShardingUpdateStatementValidator.java). 
   
   ![image](https://user-images.githubusercontent.com/3125184/100831541-d7d84100-341a-11eb-85d8-3336a726d57e.png)
   
   So the logic may be 
   ```
   if (no shardingKey in SET Clause)
       then PASS
   else if (no shardingKey in WHERE Clause)
       then append sharding column and value to WHERE Clause
   else if (the value of shardingKey in SET Clause == the value of shardingKey in WHERE Clause)
       then PASS
   else
       then an exception
   ```


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] heqiao edited a comment on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
heqiao edited a comment on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-714274455


   > > There is indeed a workaround - Embed the primary key and sharding key on the entity level. So the sharding key is disguised as part of JPA's id. Not pretty, but works... However, it's definitely not something that I could promote to coworkers "Hey we should use this cool sharding tool, and it works with JPA only if you carefully configure it"
   > 
   > It would be great if you could share an example!
   
   ```
   @Embeddable
   @Data
   public class CompositeId implements Serializable {
       private Long id; // pk
       private String accountId; // sharding key
   }
   
   @Table("xxxx")
   @Entity 
   public class YourClass {
       @EmbeddedId
       private CompositeId compositeId;
   }
   ```
   
   Then you can do findByCompositeIdAccountId.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] heqiao commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
heqiao commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-714255537


   Actually.... after a second read through of the above conversation, Trista's suggestion makes more sense. The set clause should not have sharding key. So the sharding key should not be updatable. And this solves the problem. 
   
   `@Column(name = "xxx", updatable = false)`
   
   I think I need a Rubber Duck.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] lMasterSparkl edited a comment on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
lMasterSparkl edited a comment on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-1074955190


   > @lMasterSparkl Sorry, I'm not very familiar with JPA, this may require you to study how JPA is used. Looking forward to your good news.
   
   @strongduanmu @heqiao @sabz90 @qiuxiaotong2021
   now I used interceptor to changed update sql and add sharding column in  it here is the demo
   ```
   import lombok.extern.slf4j.Slf4j;
   import org.apache.commons.lang3.StringUtils;
   import org.hibernate.EmptyInterceptor;
   import java.util.HashMap;
   import java.util.Map;
   @Slf4j
   public class AutoAddDidInterceptor extends EmptyInterceptor {
   
       public static ThreadLocal<Map<String, String>> myTable = new ThreadLocal<>();
   
       public static void setInterceptorDid(String did){
           Map<String, String> map = new HashMap<>();
           map.put("did_update", did);
           myTable.set(map);
       }
       @Override
       public String onPrepareStatement(String sql) {
           log.debug("sql interceptor worked" );
           Map<String, String> map = myTable.get();
           if (map == null) {
               return sql;
           }
           String did = map.get("did_update");
           if (StringUtils.isEmpty(did) ) {
               return sql;
           }
           //judge update sql
           if(sql.startsWith("update")){
               String[] wheres = sql.split("where");
               StringBuffer stringBuffer = new StringBuffer();
               stringBuffer.append(wheres[0]).append(" where did = '"+did+"' and ").append(wheres[1]);
               log.warn("sql has been modify and now is {}",stringBuffer.toString());
               //clean threadLocal
               myTable.remove();
               return stringBuffer.toString();
           }else{
               return sql;
           }
       }
   
   }
   ```
   and config the interceptor in config file I'm use properties
   
   ```
   spring.jpa.properties.hibernate.session_factory.session_scoped_interceptor=com.AutoAddDidInterceptor
   ```
   then use in business code like this
   ```
               AutoAddDidInterceptor.setInterceptorDid(post.getDid());
               postRepository.save(post);
   ```
   and in my test its already work to update data.
   
   but I have some Security question that if it might seen SQL injection problem.
   Welcome to point out the problem and give me some suggestion.
   hope to help the other programmers and save time.(~ ̄▽ ̄)~ 


-- 
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] tristaZero edited a comment on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
tristaZero edited a comment on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-716467242


   Hi @strongduanmu 
   I am unsure whether you are interested in [An improvement for checking update condition](https://github.com/apache/shardingsphere/issues/7703#issuecomment-716284082). Still, I guess you are the right one for it. :)  Looking for your reply, thanks.
   
   BTW, `ShardingUpdateStatementValidator` looks the target class for this 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.

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



[GitHub] [shardingsphere] strongduanmu closed issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
strongduanmu closed issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-736976180


   @strongduanmu Nice!
   Therefore, guys, another solution for this issue is to try 5.0.0-alpha. :)


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] kimmking closed issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
kimmking closed issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] kimmking commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
kimmking commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-718409450


   IMO, DONT UPDATE Sharding key SHOULD be a principle in SharidngSphere instead of an implicit configuration to point it.
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] sabz90 commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
sabz90 commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-707077359


   @tristaZero @kimmking The query does not change the Sharding key of the table. If that value does not appear in SET statement, then the query will end up being executed on all shards which is not optimal. Another option is putting the sharding column in the where clause but that gets complicated as Hibernate does not allow including columns in the where clause.
   
   maybe make this validation optional, based on some configuration?


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] strongduanmu commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-739258571


   > So a safer option would be to define an Annotation, something like "@ForceWhereClause" which should then indicate to sharding-sphere that it has to use the value from SET clause and either use that to figure out which is the target shard, or put in a where clause along in the final statement and let things happen naturally.
   
   @sabz90 I think adding annotations is a good idea, but I think it is more appropriate for hibernate to provide this annotation. 
   Users can freely control which fields are added to the `WHERE` clause and which fields are added to the `SET` clause through hibernate annotations. 


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] strongduanmu commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-739255113


   > @strongduanmu Thank you for diving into it. @tristaZero My apologies that the proposed solution may not work as I originally agreed. The where clause doesn't contain the sharding key.
   > 
   > e.g. `update ACCOUNT_INFO set name=??, account_id=??, zip=??, version=?? where id = ??` was the generated sql with account_id being the sharding key. The `shardingValue` is empty in the code @strongduanmu posted (ShardingUpdateStatementValidator.java).
   > 
   > ![image](https://user-images.githubusercontent.com/3125184/100831541-d7d84100-341a-11eb-85d8-3336a726d57e.png)
   > 
   > So the logic may be
   > 
   > ```
   > if (no shardingKey in SET Clause)
   >     then PASS
   > else if (no shardingKey in WHERE Clause)
   >     then append sharding column and value to WHERE Clause
   > else if (the value of shardingKey in SET Clause == the value of shardingKey in WHERE Clause)
   >     then PASS
   > else
   >     then an exception
   > ```
   
   @heqiao If sharding column is not included in the `WHERE` clause, can we remove the sharding column in the `SET` clause by setting the `@Column(name = "xxx", updatable = false)` annotation? 
   
   The logic you mentioned —— `then append sharding column and value to WHERE Clause`, I think it is not suitable for SS to deal with, this method will have a bad effect on other normal SQL.
   
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-716467242


   Hi @strongduanmu 
   I am unsure whether you are interested in [An improvement for checking update condition](https://github.com/apache/shardingsphere/issues/7703#issuecomment-716284082). Still, I guess you are the right one for it. :) BTW, `ShardingUpdateStatementValidator` looks the target class for this issue.
   If you are unavailable, could you tell me here?


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] lMasterSparkl commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
lMasterSparkl commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-1068775315


   > Hi @lMasterSparkl, has the value of the sharding column changed in your update statement? We have support update sharding column when the sharding routing result keep the same in pr #13906, you can try it.
   @strongduanmu 
   no the sharding column is not changed .I guess it's not execute that skip logic , here's my debug pic.
   ![compareEditShardingColumnDebug](https://user-images.githubusercontent.com/24791147/158528014-5252adce-8330-4758-8746-d60d930a0469.png)
   
   
   
   


-- 
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] strongduanmu commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-1068818841


   Through the sql that you execute, shardingsphere cannot determine whether did column has changed, so you need to specify value of did in where condition. By comparing did value in set clause with did value in where condition, shardingsphere can determine whether the data node has changed due to update statement.


-- 
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] sabz90 edited a comment on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
sabz90 edited a comment on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-737068772


   > @strongduanmu Thank you for diving into it. @tristaZero My apologies that the proposed solution may not work as I originally agreed. The where clause doesn't contain the sharding key.
   > 
   > e.g. `update ACCOUNT_INFO set name=??, account_id=??, zip=??, version=?? where id = ??` was the generated sql with account_id being the sharding key. The `shardingValue` is empty in the code @strongduanmu posted (ShardingUpdateStatementValidator.java).
   > 
   > ![image](https://user-images.githubusercontent.com/3125184/100831541-d7d84100-341a-11eb-85d8-3336a726d57e.png)
   > 
   > So the logic may be
   > 
   > ```
   > if (no shardingKey in SET Clause)
   >     then PASS
   > else if (no shardingKey in WHERE Clause)
   >     then append sharding column and value to WHERE Clause
   > else if (the value of shardingKey in SET Clause == the value of shardingKey in WHERE Clause)
   >     then PASS
   > else
   >     then an exception
   > ```
   
   The second condition will fix this issue but it is a risky option - we are just assuming that the user did not intend to put the sharding column in the SET clause. 
   
   ```
   else if (no shardingKey in WHERE Clause)
       then append sharding column and value to WHERE Clause
   ```
   
   So a safer option would be to define an Annotation, something like "@ForceWhereClause" which should then indicate to sharding-sphere that it has to use the value from SET clause and either use that to figure out which is the target shard, or put in a where clause along in the final statement and let things happen naturally.
   
   For now i have solved the problem by using CompositeKey @IdClass method , which makes hibernate include the column in where clause, but it's more of a hack since the sharding column is not really a composite key in the database level.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] sabz90 commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
sabz90 commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-714259447


   > Actually.... after a second read through of the above conversation, Trista's suggestion makes more sense. The set clause should not have sharding key. So the sharding key should not be updatable. And this solves the problem.
   > 
   > `@Column(name = "xxx", updatable = false)`
   > 
   > I think I need a Rubber Duck.
   
   But this will execute the update query in all the shards :) Which is not optimal.
   So even if the sharding column appears in the SET clause, the value may not have really changed... just that the field appears in SET clause. 
   
   Maybe there can be some annotation from sharding-sphere or some flag by which we can suppress that exception from SS because it's much more complex to explicitly include the sharding column in the where clause, especially when there's @Version involved.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-723738957


   > The title of the issue can be misleading.
   
   +1, however, users may locate this issue by the concrete exception info, I guess.
   Besides, as I said above, `updating sharding key` (comes with row migration) is supposed to be one of the capabilities for a perfect distributed database solution. Unfortunately, SS can not has better support for it but is moving towards it at present.
   Hence, we can solve this issue by having users add an annotation for JPA and avoid this exception inside SS by [digesting some cases](https://github.com/apache/shardingsphere/issues/7703#issuecomment-716284082) IMO.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-712607567


    > hibernate doesn't provide a way to include custom columns in the where clause
   
   The main point here is that the sharding key appears in select items. If you do not want to update the sharding key, could you ignore it in the list of select items?


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] strongduanmu commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-1068578341


   Hi @lMasterSparkl, has the value of the sharding column changed in your update statement? We have support update sharding column when the sharding routing result keep the same in pr #13906, you can try it.


-- 
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] strongduanmu commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-1070242297


   @lMasterSparkl Sorry, I'm not very familiar with JPA, this may require you to study how JPA is used. 
   Looking forward to your good news.


-- 
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] sabz90 commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
sabz90 commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-737068772


   > @strongduanmu Thank you for diving into it. @tristaZero My apologies that the proposed solution may not work as I originally agreed. The where clause doesn't contain the sharding key.
   > 
   > e.g. `update ACCOUNT_INFO set name=??, account_id=??, zip=??, version=?? where id = ??` was the generated sql with account_id being the sharding key. The `shardingValue` is empty in the code @strongduanmu posted (ShardingUpdateStatementValidator.java).
   > 
   > ![image](https://user-images.githubusercontent.com/3125184/100831541-d7d84100-341a-11eb-85d8-3336a726d57e.png)
   > 
   > So the logic may be
   > 
   > ```
   > if (no shardingKey in SET Clause)
   >     then PASS
   > else if (no shardingKey in WHERE Clause)
   >     then append sharding column and value to WHERE Clause
   > else if (the value of shardingKey in SET Clause == the value of shardingKey in WHERE Clause)
   >     then PASS
   > else
   >     then an exception
   > ```
   
   The second condition will fix this issue but it is a risky option - we are just assuming that the user did not intend to put the sharding column in the where clause. 
   
   ```
   else if (no shardingKey in WHERE Clause)
       then append sharding column and value to WHERE Clause
   ```
   
   So a safer option would be to define an Annotation, something like "@ForceWhereClause" which should then indicate to sharding-sphere that it has to use the value from SET clause and put in a where clause along in the final statement.
   
   For now i have solved the problem by using CompositeKey @IdClass method , which makes hibernate include the column in where clause, but it's more of a hack since the sharding column is not really a composite key in the database level.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-716284082


   Thanks for your feedback. @heqiao @sabz90 
   I read the conversation above, and gave my thinking here.
   First, the annotation `@Column(name = "xxx", updatable = false)` seems one solution to avoid `SET shardingKey=xxx`and the exception `Can not update sharding key` accordingly.
   
   Second, how to understand `But this will execute the update query in all the shards :) Which is not optimal.`? 
   Does it mean that if `@Column(name = "xxx", updatable = false)` is added, the `where clause` will not contain `shardingKey=xx`, which will cause all shards updating?
   
   Third, Do you think the following improvement is reasonable and in your expectation?
   ```JAVA
   if (no shardingKey in SET Clause)
       then PASS
   else if (the value of shardingKey in SET Clause == the value of shardingKey in WHERE Clause)
       then PASS
   else
       then an exception
   ````


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] strongduanmu commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-716477992


   > Hi @strongduanmu
   > I am unsure whether you are interested in [An improvement for checking update condition](https://github.com/apache/shardingsphere/issues/7703#issuecomment-716284082). Still, I guess you are the right one for it. :) Looking for your reply, thanks.
   > 
   > BTW, `ShardingUpdateStatementValidator` looks the target class for this issue.
   
   @tristaZero Of course, I am very willing to optimize this problem. 😀


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero edited a comment on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
tristaZero edited a comment on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-716284082


   Thanks for your feedback. @heqiao @sabz90 
   I read the conversation above, and gave my thinking here.
   
   First, the annotation `@Column(name = "xxx", updatable = false)` seems one solution to avoid `SET shardingKey=xxx`and the exception `Can not update sharding key` accordingly.
   
   Second, how to understand `But this will execute the update query in all the shards :) Which is not optimal.`? 
   Does it mean that if `@Column(name = "xxx", updatable = false)` is added, the `where clause` will not contain `shardingKey=xx`, which will cause all shards updating?
   
   Third, Do you think the following improvement is reasonable and in your expectation?
   ```JAVA
   if (no shardingKey in SET Clause)
       then PASS
   else if (the value of shardingKey in SET Clause == the value of shardingKey in WHERE Clause)
       then PASS
   else
       then an exception
   ````


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] heqiao commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
heqiao commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-722801605


   > IMO, DONT UPDATE Sharding key SHOULD be a principle in SharidngSphere instead of an implicit configuration to point it.
   
   Agreed. The uses cases for updating sharding keys are rare and probably should reconsider the sharding strategy if it did happen. However, to be clear, this question is not asking for providing capability of updating sharding keys like #8006 . The title of the issue can be misleading. 
   
   This issue is about correctly interpreting JPA generated update sqls as sharding key is included in set clause with value unchanged, thus causing misunderstanding from sharding sphere that sharding key is being updated. It's not.
   
   I just wanted to clarify in case anyone was misled by the title. 


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] qiuxiaotong2021 commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
qiuxiaotong2021 commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-914277294


   > @strongduanmu Nice!
   > Therefore, guys, another solution for this issue is to try 5.0.0-alpha. :)
   
   Hi @tristaZero , Nice!  
   Has the problem been resolved in the latest version? Or, tell me what solutions are there. After all, there are many people using spring boot JPA framework, which is not like mybatis or native jdbc orm frameworks.
   


-- 
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] kimmking commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
kimmking commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-706114796


   As @tristaZero said, sharding-key can't be update to another value cause it will change the distribution of data.
   You also can delete the old key and insert a row with new key.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] lMasterSparkl commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
lMasterSparkl commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-1068813952


   > @lMasterSparkl `update post set update_dt=?, did=?, base_like=?, base_pv=?, base_share=?, discuss=?, game_id=?, hot=?, images=?, is_delete=?, is_official=?, is_top=?, level=?, official_head=?, official_nick_name=?, official_title=?, post_id=?, pv=?, reply1did=?, reply1id=?, reply2did=?, reply2id=?, reply_did=?, share=?, tag=?, text=?, topic_id=?, topic_name=?, up=?, videos=? where id=?`
   > 
   > Judging from your sql, you are trying to update `dids` with id = ?, so this exception occurs.
   > 
   > There are two ways to solve it, 1. Do not update the did field, 2. Update the did field, and add the did condition of the same routing result to the where segment.
   
   @strongduanmu 
   **as I have say before in this comment I compared the did column and it's the same so why the excute sql do not skip did column, I think this is the Focus.**
   
   > > Hi @lMasterSparkl, has the value of the sharding column changed in your update statement? We have support update sharding column when the sharding routing result keep the same in pr #13906, you can try it.
   > > @strongduanmu
   > > no the sharding column is not changed .I guess it's not execute that skip logic , here's my debug pic.
   > > ![compareEditShardingColumnDebug](https://user-images.githubusercontent.com/24791147/158528014-5252adce-8330-4758-8746-d60d930a0469.png)
   
   


-- 
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] lMasterSparkl commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
lMasterSparkl commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-1070125715


   > Through the sql that you execute, shardingsphere cannot determine whether did column has changed, so you need to specify value of did in where condition. By comparing did value in set clause with did value in where condition, shardingsphere can determine whether the data node has changed due to update statement.
   
   oh I understand, I will try to find the way for jpa's save method that append 'where did=xxx' in it's update sql . because now I use nativeQuery such as 
   ```
       @Transactional
       @Modifying
       @Query(value = "update post set update_dt = now(),text=:#{#post.text} , images=:#{#post.images},videos=:#{#post.videos}" +
               ",base_like=:#{#post.baseLike},base_share=:#{#post.baseShare},is_top=:#{#post.getIsTop()},tag=:#{#post.tag}  " +
               "where did = :#{#post.did} and id = :#{#post.id}", nativeQuery = true)
       void updatePost(Post post);
   ```
   
   in actually we have many columns to update and it's complex with just append sharding column in where sentence , in addition   I need to judge every column is or not null .  I think use nativeQuery is  Not the original intention that use jpa. Can you give some suggestion to optimization this code.thx


-- 
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] strongduanmu commented on issue #7703: Can not update sharding key, logic table: [**], column: [**]

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-1068776773


   @lMasterSparkl Please try latest 5.1.0.


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