a1424132610 opened a new issue, #25598:
URL: https://github.com/apache/shardingsphere/issues/25598
sql
create table test1.t_user(
id bigint auto_increment primary key comment '主键id',
user_name varchar(64) default null comment '用户名称',
order_id bigint default null comment 'order_id',
index idx_order_id(order_id) comment 'order索引'
) comment '用户信息' collate = utf8mb4_general_ci;
create table test2.t_order(
id bigint auto_increment primary key comment '主键id',
`order_desc` varchar(64) default null comment '订单说明'
) comment '订单信息' collate = utf8mb4_general_ci;
yml
spring:
shardingsphere:
datasource:
names: ds1,ds2
ds1:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
jdbc-url:
jdbc:mysql://localhost:3306/test1?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&useAffectedRows=true
username: root
password: 123456
ds2:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
jdbc-url:
jdbc:mysql://localhost:3306/test2?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&useAffectedRows=true
username: root
password: 123456
sharding:
tables:
t_user:
actualDataNodes: ds1.t_user
tableStrategy:
inline:
shardingColumn: order_id
algorithmExpression: t_user
t_order:
actualDataNodes: ds2.t_order
tableStrategy:
inline:
shardingColumn: id
algorithmExpression: t_order
bindingTables:
- t_user,t_order
defaultDatabaseStrategy:
inline:
shardingColumn: order_id
algorithmExpression: ds1
query:
Page<User> page = new Page<>(1, 10);
userMapper.listByPage(page);
page.getRecords().forEach(System.out::println);
<select id="listByPage" resultMap="BaseResultMap">
select u.id, u.user_name, o.id order_id, o.order_desc from t_user u
left join t_order o on u.order_id = o.id
</select>
org.springframework.jdbc.BadSqlGrammarException:
### Error querying database. Cause: java.sql.SQLSyntaxErrorException: Table
'test1.t_order' doesn't exist
### The error may exist in com/zhj/sharding/mapper/OrderMapper.java (best
guess)
### The error may involve
com.zhj.sharding.mapper.OrderMapper.listByPage-Inline
### The error occurred while setting parameters
### SQL: select u.id, u.user_name, o.id order_id, o.order_desc from t_user u
left join t_order o on u.order_id = o.id
### Cause: java.sql.SQLSyntaxErrorException: Table 'test1.t_order' doesn't
exist
; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException:
Table 'test1.t_order' doesn't exist
Why does t_order keep looking in test1's data source?
--
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]