question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Keygenerators configured but not effective

See original GitHub issue

Which version of ShardingSphere did you use?

   shardingsphere-jdbc-core-spring-boot-starter-5.1.2

Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?

   shardingsphere-jdbc

Expected behavior

   When inserting data into the database, sharding JDBC automatically generates the ID and successfully inserts it

Actual behavior

   When inserting data in the databse,  the system throw exception:  Field 'id' doesn't have a default value

Reason analyze (If you can)

    Maybe my configuration is not effective, but my configuration is based on the example

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.

   `server.port=8888
    spring.main.allow-bean-definition-overriding=true
    spring.application.name=sharding-sphere-demo
    spring.shardingsphere.datasource.names=ds0
    spring.shardingsphere.datasource.ds0.url=jdbc:mysql://192.168.20.177/sharding_demo?useSSL=false&serverTimezone=UTC
    spring.shardingsphere.datasource.ds0.type=com.alibaba.druid.pool.DruidDataSource
    spring.shardingsphere.datasource.ds0.driver-class-name=com.mysql.cj.jdbc.Driver
    spring.shardingsphere.datasource.ds0.username=root
    spring.shardingsphere.datasource.ds0.password=
    spring.shardingsphere.mode.type=Memory
    spring.shardingsphere.rules.sharding.binding-tables=admin_email
    spring.shardingsphere.rules.sharding.sharding-algorithms.eat-auto-interval.type=auto_interval
    spring.shardingsphere.rules.sharding.sharding-algorithms.eat-auto-interval.props.datetime-lower=2022-06-01 00:00:00
    spring.shardingsphere.rules.sharding.sharding-algorithms.eat-auto-interval.props.datetime-upper=2022-09-01 00:00:00
    spring.shardingsphere.rules.sharding.sharding-algorithms.eat-auto-interval.props.sharding-seconds=2592000
    spring.shardingsphere.rules.sharding.auto-tables.admin_email.sharding-strategy.standard.sharding-column=created_at
    spring.shardingsphere.rules.sharding.auto-tables.admin_email.sharding-strategy.standard.sharding-algorithm-name=eat-auto-interval
    spring.shardingsphere.rules.sharding.auto-tables.admin_email.key-generate-strategy.column=id
    spring.shardingsphere.rules.sharding.auto-tables.admin_email.key-generate-strategy.key-generator-name=snowflake
    spring.shardingsphere.rules.sharding.auto-tables.admin_email.actualDataSources=ds0
    spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
    spring.shardingsphere.props.sql.show=true
    mybatis.type-aliases-package=com.example.eatshardingsphere.admin.mapper
    mybatis.mapper-locations=classpath:mapper/*.xml,classpath*:sdk/mapper/*.xml
    mybatis.configuration.map-underscore-to-camel-case=true
    mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl `

My excute sql

insert into admin_email(email, type, created_at) value (#{email.email}, #{email.type}, #{email.createdAt})

image

Example codes for reproduce this issue (such as a github link).

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
github-actions[bot]commented, Oct 8, 2022

Hello , this issue has not received a reply for several days. This issue is supposed to be closed.

0reactions
chenzhikun12commented, Jul 25, 2022

Can you use text to show your log? It is difficult to copy, search and investigate.

Sorry, this problem has been solved. it should be that I confused the configuration items of the old version and the new version

Read more comments on GitHub >

github_iconTop Results From Across the Web

Generating unique cache key with Spring KeyGenerator not ...
I'm having the issue when my cache keys are colliding in Spring using the @Cacheable annotation.
Read more >
Servers won't work (AES Keygenerator not available) - Jira
I have deleted and re-installed Minecraft several times since servers stopped working, but nothing changes. Tried running different Minecraft ...
Read more >
Spring Cache - Creating a Custom KeyGenerator - Baeldung
3. Custom KeyGenerator. If it isn't implemented or used correctly, it can lead to overwriting cache data. After that, we have two possible...
Read more >
Apache Hudi Key Generators
Hudi provides several key generators out of the box that users can use based on their need, while having a pluggable implementation for...
Read more >
KeyGenerator (Java Platform SE 8 ) - Oracle Help Center
Key generators are constructed using one of the getInstance class methods of ... In case the client does not explicitly initialize the KeyGenerator...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found