Shardingsphere integrates mybatis plus and reports an error. Java.lang.illegalargumentexception: sharding value must implements comparable.
error reason
because shardingsphere’s ID generation strategy is configured in the configuration file, ID is used as the partition key here, and shardingsphere will automatically generate ID value when saving data.
spring.shardingsphere.sharding.tables.user.key-generator.column = id
spring.shardingsphere.sharding.tables.user.key-generator.type = SNOWFLAKE
However, the annotation @tableid is pasted on the entity class, which conflicts with mybatis plus.
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "`user`")
public class User implements Serializable {
@TableId(value = "id", type = IdType.INPUT)
private Long id;
@TableField(value = "`name`")
private String name;
@TableField(value = "address")
private String address;
@TableField(value = "birthday")
private Date birthday;
}
The solution is not to paste @tableid when the primary key is used as the partition key. If you write SQL through an XML file, the primary key column does not need to be written
Read More:
- Sqoop Error: Can‘t parse input data: ‘\N‘ [How to Solve]
- [Solved] java.lang.ClassNotFoundException: org.apache.ibatis.session.SqlSession
- mybatis-plus calls its own selectById method and reports an error: org.apache.ibatis.binding.BindingException:
- [Solved] mybatis plus Error: Invalid bound statement (not found)
- [Solved] PhoenixParserException:ERROR 602 (42P00): Syntax error. Missing ‘EOF’
- ElasticSearch Create Index Error: mapper_parsing_exception Root mapping definition has unsupported parameters
- Kafka error: ERROR There was an error in one of the threads during logs loading: java.lang.NumberFormatException: For input string: “derby” (kafka.log.LogManager)
- How to Solve Springboot Error: Failed to convert value of type
- [How to Fix] Spring boot startup error: could not resolve placeholder
- How to Solve dtd Error in MybatisGenerator.xml file
- [Solved] Mybatis Error: Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration.
- [Solved] @webservice Error: org.apache.cxf.common.i18n.UncheckedException: No operation was found with
- How to Solve Error: Type mismatch: cannot convert from Object to Car
- Mybatis error under Springboot project: Invalid bound statement (not found)
- SpringBoot uses MyBatis error: Error invoking SqlProvider method (tk.mybatis.mapper.provider.base.BaseInsertProvider.dynamicSQL)
- [Solved] Failed to bind properties under ‘spring.datasource.type‘ to java.lang.Class<javax.sql.DataSource>
- Java.sql.SQLException: ORA-02291: integrity constraint violated – par
- Hive Error: Error: GC overhead limit exceeded
- Error starting ApplicationContext. To display the auto-configuration report re-run your application
- [Solved] Mybatis uses the PageHelper paging plugin error: Could not find method on interface ibatis.executor.Executor named query.