-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
insert with generated keys,when the last column value is null,cause NullPointerException #2252
Comments
Can you give me the
Is the last column generated Key column?And is its value null? |
like this: column "updateTime" is null,cause NullPointerException |
No,generated column is ”id“, insert sql not contains ”id“ |
I did the following test, but no exception happened.
Table structure
SQL
Do you think this example fits your scenario? By the way, can you set the props |
spring-datasource.xml:
fileMapper.xml: log: Error updating database. Cause: java.lang.NullPointerExceptionThe error may involve com.demo.file.common.dao.IFileDao.insert-InlineThe error occurred while setting parametersSQL: insert into file (orig_file_name, group_name, save_path, biz_key_id, biz_type, file_type, file_size, encrypt_version, save_type, delete_flag, create_emp, create_org, create_time,update_time ) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )Cause: java.lang.NullPointerExceptionorg.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: Error updating database. Cause: java.lang.NullPointerExceptionThe error may involve com.demo.file.common.dao.IFileDao.insert-InlineThe error occurred while setting parametersSQL: insert into file (orig_file_name, group_name, save_path, biz_key_id, biz_type, file_type, file_size, encrypt_version, save_type, delete_flag, create_emp, create_org, create_time,update_time ) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )Cause: java.lang.NullPointerException
Caused by: org.apache.ibatis.exceptions.PersistenceException: Error updating database. Cause: java.lang.NullPointerExceptionThe error may involve com.demo.file.common.dao.IFileDao.insert-InlineThe error occurred while setting parametersSQL: insert into file (orig_file_name, group_name, save_path, biz_key_id, biz_type, file_type, file_size, encrypt_version, save_type, delete_flag, create_emp, create_org, create_time,update_time ) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )Cause: java.lang.NullPointerException
Caused by: java.lang.NullPointerException |
Thanks for your reply, can you provide your |
@zhangfenghuang Hi, can you use SpringNameSpace + Mybatis + ShardingSphere examples to try to make your exception appeared? Or maybe you can provide your demo git url, so i can run your example in my computer. Waiting for your reply. |
@zhangfenghuang Hi, waiting, waiting, waiting... |
sharding-jdbc 4.0.0-RC1
<sharding:key-generator id="xxxxxx" type="SNOWFLAKE" column="id" />
useGeneratedKeys,when insert sql the last column value is null,cause NullPointerException
when update the last column,success!
exception:
Caused by: java.lang.NullPointerException
at org.apache.shardingsphere.core.route.type.standard.StandardRoutingEngine.isQualifiedInsertOptimizeResult(StandardRoutingEngine.java:221)
at org.apache.shardingsphere.core.route.type.standard.StandardRoutingEngine.reviseInsertOptimizeResult(StandardRoutingEngine.java:211)
at org.apache.shardingsphere.core.route.type.standard.StandardRoutingEngine.routeByShardingConditionsWithCondition(StandardRoutingEngine.java:110)
at org.apache.shardingsphere.core.route.type.standard.StandardRoutingEngine.routeByShardingConditions(StandardRoutingEngine.java:102)
at org.apache.shardingsphere.core.route.type.standard.StandardRoutingEngine.getDataNodes(StandardRoutingEngine.java:87)
at org.apache.shardingsphere.core.route.type.standard.StandardRoutingEngine.route(StandardRoutingEngine.java:69)
at org.apache.shardingsphere.core.route.router.sharding.ParsingSQLRouter.route(ParsingSQLRouter.java:106)
at org.apache.shardingsphere.core.route.PreparedStatementRoutingEngine.route(PreparedStatementRoutingEngine.java:66)
at org.apache.shardingsphere.core.PreparedQueryShardingEngine.route(PreparedQueryShardingEngine.java:60)
at org.apache.shardingsphere.core.BaseShardingEngine.shard(BaseShardingEngine.java:64)
at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingPreparedStatement.shard(ShardingPreparedStatement.java:224)
at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingPreparedStatement.execute(ShardingPreparedStatement.java:170)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:45)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:73)
at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:49)
at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:115)
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.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49)
at cn.uce.core.db.interceptor.BatchUpdateExecutorInterceptor.intercept(BatchUpdateExecutorInterceptor.java:79)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61)
at com.sun.proxy.$Proxy40.update(Unknown Source)
at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75)
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.apache.ibatis.plugin.Plugin.invoke(Plugin.java:63)
at com.sun.proxy.$Proxy40.update(Unknown Source)
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.apache.ibatis.plugin.Plugin.invoke(Plugin.java:63)
at com.sun.proxy.$Proxy40.update(Unknown Source)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:170)
The text was updated successfully, but these errors were encountered: