mysql删除分表键_分表:insert sql加上id分片键(分布式id),去掉则正常?

Please answer these questions before submitting your issue. Thanks!

Which version of Sharding-Jdbc do you using?

2.0.0.M2

Expected behavior

SQL加上id应该正常

Actual behavior

报错:Caused by: io.shardingjdbc.core.exception.ShardingJdbcException: Parameter null should extends Comparable for sharding value.

Steps to reproduce the behavior

使用mybatis:

1、SQL

INSERT INTO traffic (

id, name, createTime

)

VALUES (

#{id,jdbcType=BIGINT},

#{name,jdbcType=VARCHAR},

#{createTime,jdbcType=TIMESTAMP}

)

2、配置

public String doSharding(final Collection availableTargetNames, final PreciseShardingValue shardingValue) {

for (String each : availableTargetNames) {

if (each.endsWith(shardingValue.getValue() % 2 + "")) {

return each;

}

}

throw new UnsupportedOperationException();

}

3、运行

Error updating database. Cause: io.shardingjdbc.core.exception.ShardingJdbcException: Parameter null should extends Comparable for sharding value.

The error may involve defaultParameterMap

The error occurred while setting parameters

SQL: INSERT INTO traffic ( id, name, createTime ) VALUES ( ?, ?, ? )

Cause: io.shardingjdbc.core.exception.ShardingJdbcException: Parameter null should extends Comparable for sharding value.

at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)

at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:200)

at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:185)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:434)

... 7 more

Caused by: io.shardingjdbc.core.exception.ShardingJdbcException: Parameter null should extends Comparable for sharding value.

at io.shardingjdbc.core.parsing.parser.context.condition.Condition.getValues(Condition.java:100)

at io.shardingjdbc.core.parsing.parser.context.condition.Condition.getShardingValue(Condition.java:83)

at io.shardingjdbc.core.routing.type.simple.SimpleRoutingEngine.getShardingValues(SimpleRoutingEngine.java:108)

at io.shardingjdbc.core.routing.type.simple.SimpleRoutingEngine.getTableShardingValues(SimpleRoutingEngine.java:78)

at io.shardingjdbc.core.routing.type.simple.SimpleRoutingEngine.route(SimpleRoutingEngine.java:62)

at io.shardingjdbc.core.routing.router.ParsingSQLRouter.route(ParsingSQLRouter.java:120)

at io.shardingjdbc.core.routing.router.ParsingSQLRouter.route(ParsingSQLRouter.java:85)

at io.shardingjdbc.core.routing.PreparedStatementRoutingEngine.route(PreparedStatementRoutingEngine.java:57)

at io.shardingjdbc.core.jdbc.core.statement.ShardingPreparedStatement.route(ShardingPreparedStatement.java:150)

at io.shardingjdbc.core.jdbc.core.statement.ShardingPreparedStatement.execute(ShardingPreparedStatement.java:140)

at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:46)

at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74)

at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50)

at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117)

at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76)

at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:198)

... 13 more

Please provide the reproduce example codes (such as github link) if possible.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值