yage-czy commented on issue #14949: URL: https://github.com/apache/shardingsphere/issues/14949#issuecomment-1018112691
> > > > hello, my project use jpa + shardingjdbc when i use CrudRepository.save to save my data to database,jpa auto generated sql like `update table_a set field_a = 1 , field_ab = 2 where id = 3` but my sharding-key is another field "dealership_id"。So my sql execute route to all data node. I would like to ask, is there any way to deal with this situation? > > > > > > > > > I think your sql must be contains sharding_key column. > > > > > > [#970 (comment)](https://github.com/apache/shardingsphere/issues/970#issuecomment-1017241107) > > ShardingSphere not supprot route all nodes when you execute insert or save sql, Now. > > ``` > if (!routeContext.isSingleRouting() && !shardingRule.isBroadcastTable(tableName)) { > boolean isSingleDataNode = routeContext.getOriginalDataNodes().stream().allMatch(dataNodes -> dataNodes.size() == 1); > Preconditions.checkState(isSingleDataNode, "Insert statement does not support sharding table routing to multiple data nodes."); > } > ``` here is my log, this means my sql route to 2 node,aoo node? ` |- 7d70a0473c4bb3b2 -|- 7d70a0473c4bb3b2 -|- yage-demo -|- 2022-01-21 10:37:23.730 -|- INFO -|- [nio-9000-exec-1] -|- ShardingSphere-SQL [74 ] -|- Logic SQL: update ygdm_user set active_flag=?, create_time=?, create_user=?, modify_time=?, modify_user=?, version_num=?, password=?, username=? where id=? |- 7d70a0473c4bb3b2 -|- 7d70a0473c4bb3b2 -|- yage-demo -|- 2022-01-21 10:37:23.730 -|- INFO -|- [nio-9000-exec-1] -|- ShardingSphere-SQL [74 ] -|- SQLStatement: MySQLUpdateStatement(orderBy=Optional.empty, limit=Optional.empty) |- 7d70a0473c4bb3b2 -|- 7d70a0473c4bb3b2 -|- yage-demo -|- 2022-01-21 10:37:23.730 -|- INFO -|- [nio-9000-exec-1] -|- ShardingSphere-SQL [74 ] -|- Actual SQL: master-1 ::: update ygdm_user set active_flag=?, create_time=?, create_user=?, modify_time=?, modify_user=?, version_num=?, password=?, username=? where id=? ::: [1, 2022-01-20 14:02:34.0, 1, 2022-01-20 14:02:34.0, 1, 17, yage, 古力娜扎, 12] |- 7d70a0473c4bb3b2 -|- 7d70a0473c4bb3b2 -|- yage-demo -|- 2022-01-21 10:37:23.731 -|- INFO -|- [nio-9000-exec-1] -|- ShardingSphere-SQL [74 ] -|- Actual SQL: master-2 ::: update ygdm_user set active_flag=?, create_time=?, create_user=?, modify_time=?, modify_user=?, version_num=?, password=?, username=? where id=? ::: [1, 2022-01-20 14:02:34.0, 1, 2022-01-20 14:02:34.0, 1, 17, yage, 古力娜扎, 12] ` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
