You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "a1424132610 (via GitHub)" <gi...@apache.org> on 2023/05/12 01:36:09 UTC

[GitHub] [shardingsphere] a1424132610 opened a new issue, #25598: Table 'test1.t_order' doesn't exist

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: notifications-unsubscribe@shardingsphere.apache.org.apache.org

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


[GitHub] [shardingsphere] a1424132610 commented on issue #25598: Table 'test1.t_order' doesn't exist

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

   > 单表目前不支持跨库join,可以尝试开启sql-federation来执行SQL。
   
   That is to say, if I want test1.user and test2.order to perform join associated paging query, I can only enable sql-federation to support it, right?


-- 
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] a1424132610 commented on issue #25598: Table 'test1.t_order' doesn't exist

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

   > 
   
   thank you


-- 
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] a1424132610 commented on issue #25598: Table 'test1.t_order' doesn't exist

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

   > Yes.
   
   Could you please tell me where the documentation of sql-federation function is? I have looked for several versions in the official website, but did not find the documentation of sql-federation


-- 
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] Table 'test1.t_order' doesn't exist [shardingsphere]

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

   you may write issues of version 4.1.1 here :https://gitee.com/shardcn/shardingsphere_4.1.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


[GitHub] [shardingsphere] linghengqian commented on issue #25598: Table 'test1.t_order' doesn't exist

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

   > mysql version:8.0.26
   > sharding-jdbc-spring-boot-starter:4.1.1
   > mysql-connector-java:8.0.18
   
   - This feature is available on ShardingSphere 5.4.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


[GitHub] [shardingsphere] FlyingZC commented on issue #25598: Table 'test1.t_order' doesn't exist

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

   Yes.


-- 
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] a1424132610 commented on issue #25598: Table 'test1.t_order' doesn't exist

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

   mysql version:8.0.26
   sharding-jdbc-spring-boot-starter:4.1.1
   mysql-connector-java:8.0.18


-- 
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] FlyingZC commented on issue #25598: Table 'test1.t_order' doesn't exist

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

   Single table currently does not support cross-database join, you can try to enable sql-federation to execute the 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.

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

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


[GitHub] [shardingsphere] linghengqian closed issue #25598: Table 'test1.t_order' doesn't exist

Posted by "linghengqian (via GitHub)" <gi...@apache.org>.
linghengqian closed issue #25598: Table 'test1.t_order' doesn't exist
URL: https://github.com/apache/shardingsphere/issues/25598


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