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 2020/04/28 08:43:04 UTC

[GitHub] [shardingsphere] nongchangzhu opened a new issue #5367: The two lines of code in the "data sharding + read-write separation" configuration "'… key-generator.column = id' ‘… Key-generator.type = SNOWFLAKE’ ”does n’t work?

nongchangzhu opened a new issue #5367:
URL: https://github.com/apache/shardingsphere/issues/5367


   
   The springboot project configuration code is as follows:
   /----------------------------------------start---------------------------------------------------------
   
   spring.shardingsphere.datasource.names=master0,master1,master0slave0,master0slave1,master1slave0,master1slave1
   
   spring.shardingsphere.datasource.master0.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.master0.driver-class-name=com.mysql.cj.jdbc.Driver
   spring.shardingsphere.datasource.master0.jdbc-url=jdbc:mysql://localhost:3306/sharding-seata0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
   spring.shardingsphere.datasource.master0.username=root
   spring.shardingsphere.datasource.master0.password=123456
   
   spring.shardingsphere.datasource.master0slave0.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.master0slave0.driver-class-name=com.mysql.cj.jdbc.Driver
   spring.shardingsphere.datasource.master0slave0.jdbc-url=jdbc:mysql://localhost:3306/sharding-seata1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
   spring.shardingsphere.datasource.master0slave0.username=root
   spring.shardingsphere.datasource.master0slave0.password=123456
   spring.shardingsphere.datasource.master0slave1.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.master0slave1.driver-class-name=com.mysql.cj.jdbc.Driver
   spring.shardingsphere.datasource.master0slave1.jdbc-url=jdbc:mysql://localhost:3306/sharding-seata2?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
   spring.shardingsphere.datasource.master0slave1.username=root
   spring.shardingsphere.datasource.master0slave1.password=123456
   
   spring.shardingsphere.datasource.master1.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.master1.driver-class-name=com.mysql.cj.jdbc.Driver
   spring.shardingsphere.datasource.master1.jdbc-url=jdbc:mysql://localhost:3306/sharding-seata3?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
   spring.shardingsphere.datasource.master1.username=root
   spring.shardingsphere.datasource.master1.password=123456
   
   spring.shardingsphere.datasource.master1slave0.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.master1slave0.driver-class-name=com.mysql.cj.jdbc.Driver
   spring.shardingsphere.datasource.master1slave0.jdbc-url=jdbc:mysql://localhost:3306/sharding-seata4?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
   spring.shardingsphere.datasource.master1slave0.username=root
   spring.shardingsphere.datasource.master1slave0.password=123456
   spring.shardingsphere.datasource.master1slave1.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.master1slave1.driver-class-name=com.mysql.cj.jdbc.Driver
   spring.shardingsphere.datasource.master1slave1.jdbc-url=jdbc:mysql://localhost:3306/sharding-seata5?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
   spring.shardingsphere.datasource.master1slave1.username=root
   spring.shardingsphere.datasource.master1slave1.password=123456
   
   spring.shardingsphere.sharding.tables.t_order.actual-data-nodes=ds$->{0..1}.t_order$->{0..1}
   spring.shardingsphere.sharding.tables.t_order.table-strategy.inline.sharding-column=order_id
   spring.shardingsphere.sharding.tables.t_order.table-strategy.inline.algorithm-expression=t_order$->{id % 2}
   #--------------------Self-increment column name Use "SNOWFLAKE" algorithm-----------------
   spring.shardingsphere.sharding.tables.t_order.key-generator.column=id
   #spring.shardingsphere.sharding.tables.t_order.key-generator.props.worker.id=123
   spring.shardingsphere.sharding.tables.t_order.key-#generator.props.max.tolerate.time.difference.milliseconds=60000
   spring.shardingsphere.sharding.tables.t_order.key-generator.type=SNOWFLAKE
   #---------------------------------------end----------------------------------------------
   
   spring.shardingsphere.sharding.tables.t_order_item.actual-data-nodes=ds$->{0..1}.t_pay$->{0..1}
   spring.shardingsphere.sharding.tables.t_order_item.table-strategy.inline.sharding-column=id
   spring.shardingsphere.sharding.tables.t_order_item.table-strategy.inline.algorithm-expression=t_pay$->{id % 2}
   
   #--------------------Self-increment column name Use "SNOWFLAKE" algorithm-----------------
   spring.shardingsphere.sharding.tables.t_order_item.key-generator.column=id
   #spring.shardingsphere.sharding.tables.t_order_item.key-generator.props.worker.id=123
   spring.shardingsphere.sharding.tables.t_order_item.key-#generator.props.max.tolerate.time.difference.milliseconds=60000
   spring.shardingsphere.sharding.tables.t_order_item.key-generator.type=SNOWFLAKE
   #------------------------------------------end-------------------------------------------
   
   spring.shardingsphere.sharding.binding-tables=t_order,t_order_item
   #spring.shardingsphere.sharding.broadcast-tables=t_config
   
   spring.shardingsphere.sharding.default-database-strategy.inline.sharding-column=user_id
   spring.shardingsphere.sharding.default-database-strategy.inline.algorithm-expression=master$->{user_id % 2}
   
   spring.shardingsphere.sharding.master-slave-rules.ds0.master-data-source-name=master0
   spring.shardingsphere.sharding.master-slave-rules.ds0.slave-data-source-names=master0slave0, master0slave1
   spring.shardingsphere.sharding.master-slave-rules.ds1.master-data-source-name=master1
   spring.shardingsphere.sharding.master-slave-rules.ds1.slave-data-source-names=master1slave0, master1slave1
   
   /---------------------------------------------end----------------------------------------------------
   
   But still reported this exception:
   
   
   "Cause: java.sql.SQLException: Field 'id' doesn't have a default value
   ; Field 'id' doesn't have a default value; nested exception is java.sql.SQLException: Field 'id' doesn't have a default value] with root cause "


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

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



[GitHub] [shardingsphere] huangxuzhi commented on issue #5367: The two lines of code in the "data sharding + read-write separation" configuration "'… key-generator.column = id' ‘… Key-generator.type = SNOWFLAKE’ ”does n’t work?

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


   Is this solved?


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

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