我们打算每台物理数据库放多个租户,每个租户用不同的库去隔离。
tables:
sales_item:
actual-data-nodes: ds0.peach_sales_${['000001','000002','119164','FFFFFF']}.sales_item_$->{2023..2026}
配置文件中 actualDataNodes 中 peach_sales_000000 是租户数据库。目前解析出来ShardingSphere 把这个当作 ds 部分了。Actual SQL: ds0.peach_sales_119164 期望: Actual SQL: ds0 ::: SELECT * FROM peach_sales_119164.sales_item_2025 WHERE ..., 实际是下面结果。
ShardingSphere-SQL : Logic SQL: SELECT id, `shop_id`, `brand_id`, `sales_date`, `item_id`, `supplier_id`, tenant_id, create_time FROM sales_item WHERE (`sales_date` = ? AND id = ?) AND tenant_id = '119164'
ShardingSphere-SQL : SQLStatement: MySQLSelectStatement(super=SelectStatement(super=AbstractSQLStatement(parameterCount=2, parameterMarkerSegments=[ParameterMarkerExpressionSegment(startIndex=135, stopIndex=135, parameterMarkerIndex=0, parameterMarkerType=QUESTION, alias=Optional.empty), ParameterMarkerExpressionSegment(startIndex=146, stopIndex=146, parameterMarkerIndex=1, parameterMarkerType=QUESTION, alias=Optional.empty)], commentSegments=[]), projections=ProjectionsSegment(startIndex=7, stopIndex=95, projections=[ColumnProjectionSegment(column=ColumnSegment(startIndex=7, stopIndex=8, identifier=IdentifierValue(value=id, quoteCharacter=NONE), owner=Optional.empty), alias=Optional.empty), ColumnProjectionSegment(column=ColumnSegment(startIndex=11, stopIndex=19, identifier=IdentifierValue(value=shop_id, quoteCharacter=BACK_QUOTE), owner=Optional.empty), alias=Optional.empty), ColumnProjectionSegment(column=ColumnSegment(startIndex=22, stopIndex=31, identifier=IdentifierValue(value=brand_id, quoteCharacter=BACK_QUOTE), owner=Optional.empty), alias=Optional.empty), ColumnProjectionSegment(column=ColumnSegment(startIndex=34, stopIndex=45, identifier=IdentifierValue(value=sales_date, quoteCharacter=BACK_QUOTE), owner=Optional.empty), alias=Optional.empty), ColumnProjectionSegment(column=ColumnSegment(startIndex=48, stopIndex=56, identifier=IdentifierValue(value=item_id, quoteCharacter=BACK_QUOTE), owner=Optional.empty), alias=Optional.empty), ColumnProjectionSegment(column=ColumnSegment(startIndex=59, stopIndex=71, identifier=IdentifierValue(value=supplier_id, quoteCharacter=BACK_QUOTE), owner=Optional.empty), alias=Optional.empty), ColumnProjectionSegment(column=ColumnSegment(startIndex=74, stopIndex=82, identifier=IdentifierValue(value=tenant_id, quoteCharacter=NONE), owner=Optional.empty), alias=Optional.empty), ColumnProjectionSegment(column=ColumnSegment(startIndex=85, stopIndex=95, identifier=IdentifierValue(value=create_time, quoteCharacter=NONE), owner=Optional.empty), alias=Optional.empty)], distinctRow=false), from=SimpleTableSegment(tableName=TableNameSegment(startIndex=102, stopIndex=111, identifier=IdentifierValue(value=sales_item, quoteCharacter=NONE)), owner=Optional.empty, alias=Optional.empty), where=Optional[WhereSegment(startIndex=113, stopIndex=172, expr=BinaryOperationExpression(startIndex=119, stopIndex=172, left=BinaryOperationExpression(startIndex=120, stopIndex=146, left=BinaryOperationExpression(startIndex=120, stopIndex=135, left=ColumnSegment(startIndex=120, stopIndex=131, identifier=IdentifierValue(value=sales_date, quoteCharacter=BACK_QUOTE), owner=Optional.empty), right=ParameterMarkerExpressionSegment(startIndex=135, stopIndex=135, parameterMarkerIndex=0, parameterMarkerType=QUESTION, alias=Optional.empty), operator==, text=`sales_date` = ?), right=BinaryOperationExpression(startIndex=141, stopIndex=146, left=ColumnSegment(startIndex=141, stopIndex=142, identifier=IdentifierValue(value=id, quoteCharacter=NONE), owner=Optional.empty), right=ParameterMarkerExpressionSegment(startIndex=146, stopIndex=146, parameterMarkerIndex=1, parameterMarkerType=QUESTION, alias=Optional.empty), operator==, text=id = ?), operator=AND, text=`sales_date` = ? AND id = ?), right=BinaryOperationExpression(startIndex=153, stopIndex=172, left=ColumnSegment(startIndex=153, stopIndex=161, identifier=IdentifierValue(value=tenant_id, quoteCharacter=NONE), owner=Optional.empty), right=LiteralExpressionSegment(startIndex=165, stopIndex=172, literals=119164), operator==, text=tenant_id = '119164'), operator=AND, text=(`sales_date` = ? AND id = ?) AND tenant_id = '119164'))], groupBy=Optional.empty, having=Optional.empty, orderBy=Optional.empty, combine=Optional.empty), table=Optional.empty, limit=Optional.empty, lock=Optional.empty, window=Optional.empty)
ShardingSphere-SQL : Actual SQL: ds0.peach_sales_119164 ::: SELECT id, `shop_id`, `brand_id`, `sales_date`, `item_id`, `supplier_id`, tenant_id, create_time FROM sales_item_2025 WHERE (`sales_date` = ? AND id = ?) AND tenant_id = '119164' ::: [2025-01-01, 2]
org.springframework.jdbc.UncategorizedSQLException:
### Error querying database. Cause: java.sql.SQLException: Unknown exception: Missing the data source name: 'ds0.peach_sales_119164'
- 热议问题
-
boot版本没有actuator
1
-
rider运行到安卓模拟器上,这里怎么配置呀,请求不到后台接口,运行到网页可以
1
-
在业务类调用dingtalk问题
1
-
http://localhost:8088/blade-auth/oauth/token 报错
1
-
用户不存在提示
1
-
组态中如何通过输入框将信息传递给设备?
1
-
spring boot 4.6 版本 加入了 乐观锁 数据审计功能的hander 就失效了
2
-
blade-x 单体框架,如何对prod 文件的 所有的接口返回值加密
1
-
bladex spring boot版本 登录如何与前端对接呢?
1
-
品类导入失败
2
扫一扫访问 Blade技术社区 移动端