You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/08/02 03:29:16 UTC

[GitHub] [shardingsphere] xiaotong2019 opened a new issue, #19769: Calling the insert method cannot return the PK primary key value.

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

   ## Calling the insert method cannot return the PK primary key value.
   
   When shardingsphere v5.1.2 integrates mybatis-plus v3.5.2, calling the insert method successfully, but cannot return the PK primary key value (I using the default snowflake algorithm and build in spring boot v2.3.12 and mysql 8).
   
   Help, Thanks!
   
   ### version:
   <dependency>
               <groupId>com.baomidou</groupId>
               <artifactId>mybatis-plus-boot-starter</artifactId>
               <version>3.5.2</version>
           </dependency>
           <dependency>
               <groupId>mysql</groupId>
               <artifactId>mysql-connector-java</artifactId>
               <scope>runtime</scope>
           </dependency>
           <dependency>
               <groupId>org.apache.shardingsphere</groupId>
               <artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
               <version>5.1.2</version>
           </dependency>
   
   ![image](https://user-images.githubusercontent.com/110440830/182285464-b519dc7c-e1c5-4ce7-9595-b96e2b8615dd.png)
   


-- 
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] terrymanu commented on issue #19769: Calling the insert method cannot return the PK primary key value.

Posted by GitBox <gi...@apache.org>.
terrymanu commented on issue #19769:
URL: https://github.com/apache/shardingsphere/issues/19769#issuecomment-1203966760

   What is your configuration?


-- 
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] xiaotong2019 closed issue #19769: Calling the insert method cannot return the PK primary key value.

Posted by GitBox <gi...@apache.org>.
xiaotong2019 closed issue #19769: Calling the insert method cannot return the PK primary key value.
URL: https://github.com/apache/shardingsphere/issues/19769


-- 
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] xiaotong2019 commented on issue #19769: Calling the insert method cannot return the PK primary key value.

Posted by GitBox <gi...@apache.org>.
xiaotong2019 commented on issue #19769:
URL: https://github.com/apache/shardingsphere/issues/19769#issuecomment-1205303098

   > What is your configuration?
   
   I found a neat solution, but probably not the most appropriate.
   On the primary key field of the mybatis-plus entity class, add the @TableId(type = IdType.AUTO) declaration.
   Or, there are other more reasonable solutions, Pls reply me, thanks very much.
   


-- 
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] xiaotong2019 commented on issue #19769: Calling the insert method cannot return the PK primary key value.

Posted by GitBox <gi...@apache.org>.
xiaotong2019 commented on issue #19769:
URL: https://github.com/apache/shardingsphere/issues/19769#issuecomment-1204673445

   > What is your configuration?
   
   Thanks, Such as: 
   
   `server.port=8080
   
   mybatis-plus.mapper-locations=classpath:mybatis/**/*.xml
   mybatis-plus.type-aliases-package=com.catfish.**.domain
   mybatis-plus.configuration.map-underscore-to-camel-case=true
   
   spring.shardingsphere.enabled=true
   spring.shardingsphere.mode.type=Memory
   spring.shardingsphere.props.sql-show=true
   
   spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
   spring.shardingsphere.rules.sharding.key-generators.snowflake.props.worker-id=123
   
   spring.shardingsphere.datasource.names=ds0,ds1
   spring.shardingsphere.datasource.ds0.jdbc-url=jdbc:mysql://localhost:3306/ds0?serverTimezone=GMT%2B8&useSSL=false&useUnicode=true&characterEncoding=UTF-8
   spring.shardingsphere.datasource.ds0.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.ds0.driver-class-name=com.mysql.cj.jdbc.Driver
   spring.shardingsphere.datasource.ds0.username=root
   spring.shardingsphere.datasource.ds0.password=root1234
   spring.shardingsphere.datasource.ds0.minimum-idle=2
   spring.shardingsphere.datasource.ds0.maximum-pool-size=5
   
   spring.shardingsphere.datasource.ds1.jdbc-url=jdbc:mysql://localhost:3306/ds1?serverTimezone=GMT%2B8&useSSL=false&useUnicode=true&characterEncoding=UTF-8
   spring.shardingsphere.datasource.ds1.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.ds1.driver-class-name=com.mysql.cj.jdbc.Driver
   spring.shardingsphere.datasource.ds1.username=root
   spring.shardingsphere.datasource.ds1.password=root1234
   spring.shardingsphere.datasource.ds1.minimum-idle=2
   spring.shardingsphere.datasource.ds1.maximum-pool-size=5
   
   spring.shardingsphere.rules.sharding.tables.t_order.actual-data-nodes=ds$->{0..1}.t_order_$->{0..1}
   spring.shardingsphere.rules.sharding.tables.t_order_item.actual-data-nodes=ds$->{0..1}.t_order_item_$->{0..1}
   spring.shardingsphere.rules.sharding.tables.t_user.actual-data-nodes=ds$->{0..1}.t_user_$->{0..1}
   
   spring.shardingsphere.rules.sharding.binding-tables=t_order,t_order_item
   spring.shardingsphere.rules.sharding.broadcast-tables=t_dict
   
   spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.column=order_id
   spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.key-generator-name=snowflake
   spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.column=item_id
   spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.key-generator-name=snowflake
   spring.shardingsphere.rules.sharding.tables.t_user.key-generate-strategy.column=user_id
   spring.shardingsphere.rules.sharding.tables.t_user.key-generate-strategy.key-generator-name=snowflake
   spring.shardingsphere.rules.sharding.tables.t_dict.key-generate-strategy.column=id
   spring.shardingsphere.rules.sharding.tables.t_dict.key-generate-strategy.key-generator-name=snowflake
   
   spring.shardingsphere.rules.sharding.tables.t_order.database-strategy.standard.sharding-column=order_id
   spring.shardingsphere.rules.sharding.tables.t_order.database-strategy.standard.sharding-algorithm-name=db-order
   spring.shardingsphere.rules.sharding.tables.t_order_item.database-strategy.standard.sharding-column=order_id
   spring.shardingsphere.rules.sharding.tables.t_order_item.database-strategy.standard.sharding-algorithm-name=db-order
   spring.shardingsphere.rules.sharding.tables.t_user.database-strategy.standard.sharding-column=user_id
   spring.shardingsphere.rules.sharding.tables.t_user.database-strategy.standard.sharding-algorithm-name=db-user
   
   spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-column=order_id
   spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-algorithm-name=tb-order
   spring.shardingsphere.rules.sharding.tables.t_order_item.table-strategy.standard.sharding-column=order_id
   spring.shardingsphere.rules.sharding.tables.t_order_item.table-strategy.standard.sharding-algorithm-name=tb-order-item
   spring.shardingsphere.rules.sharding.tables.t_user.table-strategy.standard.sharding-column=user_id
   spring.shardingsphere.rules.sharding.tables.t_user.table-strategy.standard.sharding-algorithm-name= tb-user
   
   spring.shardingsphere.rules.sharding.sharding-algorithms.db-order.type=INLINE
   spring.shardingsphere.rules.sharding.sharding-algorithms.db-order.props.algorithm-expression=ds$->{ order_id % 2 }
   spring.shardingsphere.rules.sharding.sharding-algorithms.tb-order.type=INLINE
   spring.shardingsphere.rules.sharding.sharding-algorithms.tb-order.props.algorithm-expression=t_order_$->{ order_id % 2 }
   
   spring.shardingsphere.rules.sharding.sharding-algorithms.db-order-item.type=INLINE
   spring.shardingsphere.rules.sharding.sharding-algorithms.db-order-item.props.algorithm-expression=ds$->{ order_id % 2 }
   spring.shardingsphere.rules.sharding.sharding-algorithms.tb-order-item.type=INLINE
   spring.shardingsphere.rules.sharding.sharding-algorithms.tb-order-item.props.algorithm-expression=t_order_item_$->{ order_id % 2 }
   
   spring.shardingsphere.rules.sharding.sharding-algorithms.db-user.type=INLINE
   spring.shardingsphere.rules.sharding.sharding-algorithms.db-user.props.algorithm-expression=ds$->{ user_id % 2 }
   spring.shardingsphere.rules.sharding.sharding-algorithms.tb-user.type=INLINE
   spring.shardingsphere.rules.sharding.sharding-algorithms.tb-user.props.algorithm-expression=t_user_$->{ user_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