You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "JianfeiMa (via GitHub)" <gi...@apache.org> on 2024/06/10 09:02:59 UTC

[I] How to resolve problem that java.sql.SQLException: Please check your sharding conditions 'ShardingConditions(conditions=[ShardingCondition(values=[t_ent_order_item.order_id = 2], startIndex=0)], sqlStatementContext=org.apache.shardingsphere.infra.binder.context.statement.dml.InsertStatementContext@6c4595d1, rule=org.apache.shardingsphere.sharding.rule.ShardingRule@5342032a, subqueryContainsShardingCondition=true)' to avoid same record in table 't_ent_order_item' routing to multiple data nodes. at org.apache.shardingsphere.infra.exception.core.external.sql.ShardingSphereSQLException.toSQLException(ShardingSphereSQLException.java:76) at org.apache.shardingsphere.infra.exception.dialect.SQLExceptionTransformEngine.toSQLException(SQLExceptionTransformEngine.java:54) at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.executeUpdate(ShardingSpherePreparedStatement.java:367) at com.example.shardingsphere.ShardingsphereApplication.main(ShardingsphereApplication.java:57) [shardingsphere]

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

   java.sql.SQLException: Please check your sharding conditions 'ShardingConditions(conditions=[ShardingCondition(values=[t_ent_order_item.order_id = 2], startIndex=0)], sqlStatementContext=org.apache.shardingsphere.infra.binder.context.statement.dml.InsertStatementContext@6c4595d1, rule=org.apache.shardingsphere.sharding.rule.ShardingRule@5342032a, subqueryContainsShardingCondition=true)' to avoid same record in table 't_ent_order_item' routing to multiple data nodes.
   	at org.apache.shardingsphere.infra.exception.core.external.sql.ShardingSphereSQLException.toSQLException(ShardingSphereSQLException.java:76)
   	at org.apache.shardingsphere.infra.exception.dialect.SQLExceptionTransformEngine.toSQLException(SQLExceptionTransformEngine.java:54)
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.executeUpdate(ShardingSpherePreparedStatement.java:367)
   	at com.example.shardingsphere.ShardingsphereApplication.main(ShardingsphereApplication.java:57)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org.apache.org

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


Re: [I] How to resolve problem that java.sql.SQLException: Please check your sharding conditions 'ShardingConditions(conditions=[ShardingCondition(values=[t_ent_order_item.order_id = 2], startIndex=0)], sqlStatementContext=org.apache.shardingsphere.infra.binder.context.statement.dml.InsertStatementContext@6c4595d1, rule=org.apache.shardingsphere.sharding.rule.ShardingRule@5342032a, subqueryContainsShardingCondition=true)' to avoid same record in table 't_ent_order_item' routing to multiple data nodes. at org.apache.shardingsphere.infra.exception.core.external.sql.ShardingSphereSQLException.toSQLException(ShardingSphereSQLException.java:76) at org.apache.shardingsphere.infra.exception.dialect.SQLExceptionTransformEngine.toSQLException(SQLExceptionTransformEngine.java:54) at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.executeUpdate(ShardingSpherePreparedStatement.java:367) at com.example.shardingsphere.ShardingsphereApplication.main(ShardingsphereApplication.java:57) [shardingsphere]

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

   My configuration :
   java.util.Properties propertiesForTEntOrderItem = new java.util.Properties();
           propertiesForTEntOrderItem.setProperty("algorithm-expression", "t_ent_order_item_${order_id % 2}");
           org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration algorithmConfigurationForTEntOrderItem = new org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration("INLINE", propertiesForTEntOrderItem);
           stringAlgorithmConfigurationMap.put("t_ent_order_item_line", algorithmConfigurationForTEntOrderItem);
   
   ShardingTableRuleConfiguration shardingTableRuleConfiguration = new ShardingTableRuleConfiguration("t_ent_order_item", "ds_${0..3}.t_ent_order_item_${[0, 1, 2, 3, 4, 5, 6, 7]}");
           shardingTableRuleConfiguration.setKeyGenerateStrategy(new KeyGenerateStrategyConfiguration("id", "snowflake"));
           shardingTableRuleConfiguration.setTableShardingStrategy(new StandardShardingStrategyConfiguration("order_id", "t_ent_order_item_line"));


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

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


Re: [I] How to resolve problem that java.sql.SQLException: Please check your sharding conditions 'ShardingConditions(conditions=[ShardingCondition(values=[t_ent_order_item.order_id = 2], startIndex=0)], sqlStatementContext=org.apache.shardingsphere.infra.binder.context.statement.dml.InsertStatementContext@6c4595d1, rule=org.apache.shardingsphere.sharding.rule.ShardingRule@5342032a, subqueryContainsShardingCondition=true)' to avoid same record in table 't_ent_order_item' routing to multiple data nodes. at org.apache.shardingsphere.infra.exception.core.external.sql.ShardingSphereSQLException.toSQLException(ShardingSphereSQLException.java:76) at org.apache.shardingsphere.infra.exception.dialect.SQLExceptionTransformEngine.toSQLException(SQLExceptionTransformEngine.java:54) at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.executeUpdate(ShardingSpherePreparedStatement.java:367) at com.example.shardingsphere.ShardingsphereApplication.main(ShardingsphereApplication.java:57) [shardingsphere]

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

   我把算法表达式改成propertiesForTEntOrderItem.setProperty("algorithm-expression", "t_ent_order_item_${order_id % 8}");


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

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


Re: [I] How to resolve problem that java.sql.SQLException: Please check your sharding conditions 'ShardingConditions(conditions=[ShardingCondition(values=[t_ent_order_item.order_id = 2], startIndex=0)], sqlStatementContext=org.apache.shardingsphere.infra.binder.context.statement.dml.InsertStatementContext@6c4595d1, rule=org.apache.shardingsphere.sharding.rule.ShardingRule@5342032a, subqueryContainsShardingCondition=true)' to avoid same record in table 't_ent_order_item' routing to multiple data nodes. at org.apache.shardingsphere.infra.exception.core.external.sql.ShardingSphereSQLException.toSQLException(ShardingSphereSQLException.java:76) at org.apache.shardingsphere.infra.exception.dialect.SQLExceptionTransformEngine.toSQLException(SQLExceptionTransformEngine.java:54) at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.executeUpdate(ShardingSpherePreparedStatement.java:367) at com.example.shardingsphere.ShardingsphereApplication.main(ShardingsphereApplication.java:57) [shardingsphere]

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

   PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO t_ent_order_item(ent_id, region_code, good_id, good_name, order_id) VALUES (?, ?, ?, ?, ?);");
               preparedStatement.setInt(1, 2024);
               preparedStatement.setString(2, "GD");
               preparedStatement.setString(3, "abc123");
               preparedStatement.setString(4, "研究ShardingSphere");
               preparedStatement.setInt(5, 16);
               int result = preparedStatement.executeUpdate();
               System.out.println("打印插入结果->" + result);
               我通过这段代码插入一条记录然后就抛出如下异常:
               java.sql.SQLException: Please check your sharding conditions 'ShardingConditions(conditions=[ShardingCondition(values=[t_ent_order_item.order_id = 16], startIndex=0)], sqlStatementContext=org.apache.shardingsphere.infra.binder.context.statement.dml.InsertStatementContext@600428ad, rule=org.apache.shardingsphere.sharding.rule.ShardingRule@5342032a, subqueryContainsShardingCondition=true)' to avoid same record in table 't_ent_order_item' routing to multiple data nodes.
   	at org.apache.shardingsphere.infra.exception.core.external.sql.ShardingSphereSQLException.toSQLException(ShardingSphereSQLException.java:76)
   	at org.apache.shardingsphere.infra.exception.dialect.SQLExceptionTransformEngine.toSQLException(SQLExceptionTransformEngine.java:54)
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.executeUpdate(ShardingSpherePreparedStatement.java:367)
   	at com.example.shardingsphere.ShardingsphereApplication.main(ShardingsphereApplication.java:57)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

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


Re: [I] How to resolve problem that java.sql.SQLException: Please check your sharding conditions 'ShardingConditions(conditions=[ShardingCondition(values=[t_ent_order_item.order_id = 2], startIndex=0)], to avoid same record in table 't_ent_order_item' routing to multiple data nodes. [shardingsphere]

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

   问题原因是:
   当分片表规则配置的实际数据节点是这样demo_ds_${0,1}.t_order_${[0, 1]}的时候,最终会拆分成笛卡尔乘积,所以在查询的时候会分别查询两个数据的两个表,但是当插入数据的时候就抛出以上错误,当我改成demo_ds_${0}.t_order_${[0, 1]}再次插入数据的时候就不会抛出异常了;如果要路由多个数据库的时候又该如何配置呢?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

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


Re: [I] How to resolve problem that java.sql.SQLException: Please check your sharding conditions 'ShardingConditions(conditions=[ShardingCondition(values=[t_ent_order_item.order_id = 2], startIndex=0)], sqlStatementContext=org.apache.shardingsphere.infra.binder.context.statement.dml.InsertStatementContext@6c4595d1, rule=org.apache.shardingsphere.sharding.rule.ShardingRule@5342032a, subqueryContainsShardingCondition=true)' to avoid same record in table 't_ent_order_item' routing to multiple data nodes. at org.apache.shardingsphere.infra.exception.core.external.sql.ShardingSphereSQLException.toSQLException(ShardingSphereSQLException.java:76) at org.apache.shardingsphere.infra.exception.dialect.SQLExceptionTransformEngine.toSQLException(SQLExceptionTransformEngine.java:54) at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.executeUpdate(ShardingSpherePreparedStatement.java:367) at com.example.shardingsphere.ShardingsphereApplication.main(ShardingsphereApplication.java:57) [shardingsphere]

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

   algorithm-expression=t_ent_order_item_${order_id % 2}


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

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


Re: [I] How to resolve problem that java.sql.SQLException: Please check your sharding conditions 'ShardingConditions(conditions=[ShardingCondition(values=[t_ent_order_item.order_id = 2], startIndex=0)], sqlStatementContext=org.apache.shardingsphere.infra.binder.context.statement.dml.InsertStatementContext@6c4595d1, rule=org.apache.shardingsphere.sharding.rule.ShardingRule@5342032a, subqueryContainsShardingCondition=true)' to avoid same record in table 't_ent_order_item' routing to multiple data nodes. at org.apache.shardingsphere.infra.exception.core.external.sql.ShardingSphereSQLException.toSQLException(ShardingSphereSQLException.java:76) at org.apache.shardingsphere.infra.exception.dialect.SQLExceptionTransformEngine.toSQLException(SQLExceptionTransformEngine.java:54) at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.executeUpdate(ShardingSpherePreparedStatement.java:367) at com.example.shardingsphere.ShardingsphereApplication.main(ShardingsphereApplication.java:57) [shardingsphere]

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

   还是不行,报同样的错误


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

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


Re: [I] How to resolve problem that java.sql.SQLException: Please check your sharding conditions 'ShardingConditions(conditions=[ShardingCondition(values=[t_ent_order_item.order_id = 2], startIndex=0)], sqlStatementContext=org.apache.shardingsphere.infra.binder.context.statement.dml.InsertStatementContext@6c4595d1, rule=org.apache.shardingsphere.sharding.rule.ShardingRule@5342032a, subqueryContainsShardingCondition=true)' to avoid same record in table 't_ent_order_item' routing to multiple data nodes. at org.apache.shardingsphere.infra.exception.core.external.sql.ShardingSphereSQLException.toSQLException(ShardingSphereSQLException.java:76) at org.apache.shardingsphere.infra.exception.dialect.SQLExceptionTransformEngine.toSQLException(SQLExceptionTransformEngine.java:54) at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.executeUpdate(ShardingSpherePreparedStatement.java:367) at com.example.shardingsphere.ShardingsphereApplication.main(ShardingsphereApplication.java:57) [shardingsphere]

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

   Hi @JianfeiMa, can you modify the issue title for search friendly?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

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


Re: [I] How to resolve problem that java.sql.SQLException: Please check your sharding conditions 'ShardingConditions(conditions=[ShardingCondition(values=[t_ent_order_item.order_id = 2], startIndex=0)], to avoid same record in table 't_ent_order_item' routing to multiple data nodes. [shardingsphere]

Posted by "JianfeiMa (via GitHub)" <gi...@apache.org>.
JianfeiMa closed issue #31647: How to resolve problem that java.sql.SQLException: Please check your sharding conditions 'ShardingConditions(conditions=[ShardingCondition(values=[t_ent_order_item.order_id = 2], startIndex=0)], to avoid same record in table 't_ent_order_item' routing to multiple data nodes.
URL: https://github.com/apache/shardingsphere/issues/31647


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