PeiMouRen commented on issue #19541:
URL: 
https://github.com/apache/shardingsphere/issues/19541#issuecomment-1197938176

   **Environment:**
   jdk:1.8
   spring boot:2.6.4
   shardingsphere-jdbc:5.1.2
   postgresql:12.6
   ---
   **spring boot config:**
   ```yaml
   spring:
     shardingsphere:
       database:
         name:
       mode:
         type: Standalone
         repository:
           type: File
           props:
             path: .shardingsphere
         overwrite: true
       datasource:
         names: ds0, ds1
         ds0:
           type: com.zaxxer.hikari.HikariDataSource
           driver-class-name: org.postgresql.Driver
           jdbc-url: 
jdbc:postgresql://localhost:5432/shard1?stringtype=unspecified
           username: root
           password: 123
         ds1:
           type: com.zaxxer.hikari.HikariDataSource
           driver-class-name: org.postgresql.Driver
           jdbc-url: 
jdbc:postgresql://localhost:5432/shard2?stringtype=unspecified
           username: root
           password: 123
       rules:
         sharding:
           tables:
             t_order: 
               actual-data-nodes: ds$->{0..1}.t_order_$->{0..1}
               database-strategy:
                 standard:
                   sharding-column: user_id
                   sharding-algorithm-name: database-inline
               table-strategy:
                 standard:
                   sharding-column: order_id 
                   sharding-algorithm-name: t-order-inline
               key-generate-strategy: 
                 column: order_id 
                 key-generator-name: snowflake
           sharding-algorithms:
             database-inline:
               type: INLINE 
               props:
                 algorithm-expression: ds$->{user_id % 2}
             t-order-inline:
               type: INLINE
               props:
                 algorithm-expression: t_order_$->{order_id % 2}
           key-generators:
             snowflake: 
               type: SNOWFLAKE 
       props:
         sql-show: true
   
   
   ```
   ---
   **DDL:**
   ```sql
   # ds0
   create table t_order_0(order_id bigint, user_id int, remark varchar(200));
   create table t_order_1(order_id bigint, user_id int, remark varchar(200));
   # ds1
   create table t_order_0(order_id bigint, user_id int, remark varchar(200));
   create table t_order_1(order_id bigint, user_id int, remark varchar(200));
   ```
   ---
   **sql:**
   ```java
   
   ...
      @Insert("insert into t_order(user_id, remark) values ( #{userId}, 
#{remark})")
       void add4(@Param("userId") int userId, @Param("remark") String remark);
   ...
   
   orderDao.add4(100, "test");
   ```
   ---
   **error:**
   Because no order_id was generated.
   this error disappeared when I switched the data source to mysql.
   ```
   org.mybatis.spring.MyBatisSystemException: nested exception is 
org.apache.ibatis.exceptions.PersistenceException: 
   ### Error updating database.  Cause: java.lang.IllegalStateException: Insert 
statement does not support sharding table routing to multiple data nodes.
   ### The error may exist in com/lhx/shardingjdbcdemo/dao/OrderDao.java (best 
guess)
   ### The error may involve com.lhx.shardingjdbcdemo.dao.OrderDao.add4-Inline
   ### The error occurred while setting parameters
   ### SQL: insert into t_order(user_id, remark) values ( ?, ?)
   ```
   


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

Reply via email to