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 2022/02/23 07:01:23 UTC

[GitHub] [shardingsphere] larrychen8276 opened a new issue #15578: spring JdbcTemplate insert cann't support return key

larrychen8276 opened a new issue #15578:
URL: https://github.com/apache/shardingsphere/issues/15578


   ## Bug Report
   
   **For English only**, other languages will not accept.
   
   Before report a bug, make sure you have:
   
   - Searched open and closed [GitHub issues](https://github.com/apache/shardingsphere/issues).
   - Read documentation: [ShardingSphere Doc](https://shardingsphere.apache.org/document/current/en/overview).
   
   Please pay attention on issues you submitted, because we maybe need more details. 
   If no response anymore and we cannot reproduce it on current information, we will **close it**.
   
   Please answer these questions before submitting your issue. Thanks!
   
   ### Which version of ShardingSphere did you use?
   5.1.0
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-JDBC
   
   ### Expected behavior
   ```
   14:47:43.803 [http-nio-70-exec-4] INFO  ShardingSphere-SQL:74- Actual SQL: dataSourceMysqlMaster ::: insert into c_z_role(name,remark) values (?,?) ::: [eee, eee]
   2月 23, 2022 2:47:43 δΈ‹εˆ org.apache.catalina.core.StandardWrapperValve invoke
   SEVERE: Servlet.service() for servlet [springMvc] in context with path [/core] threw exception [Request processing failed; nested exception is java.lang.NullPointerException: Cannot invoke "String.toLowerCase(java.util.Locale)" because "key" is null] with root cause
   java.lang.NullPointerException: Cannot invoke "String.toLowerCase(java.util.Locale)" because "key" is null
   	at org.springframework.util.LinkedCaseInsensitiveMap.convertKey(LinkedCaseInsensitiveMap.java:332)
   	at org.springframework.util.LinkedCaseInsensitiveMap.putIfAbsent(LinkedCaseInsensitiveMap.java:212)
   	at org.springframework.util.LinkedCaseInsensitiveMap.putIfAbsent(LinkedCaseInsensitiveMap.java:49)
   	at org.springframework.jdbc.core.ColumnMapRowMapper.mapRow(ColumnMapRowMapper.java:55)
   	at org.springframework.jdbc.core.ColumnMapRowMapper.mapRow(ColumnMapRowMapper.java:46)
   	at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:94)
   	at org.springframework.jdbc.core.JdbcTemplate.lambda$update$3(JdbcTemplate.java:1000)
   	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:651)
   	at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:991)
   ```
   
   ### Actual behavior
   
   ### Reason analyze (If you can)
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   
   ### Example codes for reproduce this issue (such as a github link).
   ```
   public Integer insertPrimaryKey(final SysRole entity) {
   		KeyHolder keyHolder = new GeneratedKeyHolder();
   
   		getJdbcTemplate().update(new PreparedStatementCreator() {
   			public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {
   				PreparedStatement ps = connection.prepareStatement("insert into c_z_role (name, remark) values (?, ?)", Statement.RETURN_GENERATED_KEYS);
   				ps.setString(1, entity.getName());
   				ps.setString(2, entity.getRemark());
   				return ps;
   			}
   		}, keyHolder);
   
   		return keyHolder.getKey().intValue();
   	}
   ```
   


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

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

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



[GitHub] [shardingsphere] strongduanmu edited a comment on issue #15578: spring JdbcTemplate insert cann't support return key

Posted by GitBox <gi...@apache.org>.
strongduanmu edited a comment on issue #15578:
URL: https://github.com/apache/shardingsphere/issues/15578#issuecomment-1067510271


   Hi @larrychen8276, do you try the latest master branch?


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

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

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



[GitHub] [shardingsphere] strongduanmu commented on issue #15578: spring JdbcTemplate insert cann't support return key

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


   > 
   
   You are welcome, looking forward to your test result.


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

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

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



[GitHub] [shardingsphere] larrychen8276 commented on issue #15578: spring JdbcTemplate insert cann't support return key

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


   > @larrychen8276 Can you provide your configuration? Besides, you can look at this issue #15451, maybe they are same problems.
   [spring-mysql-readwrite-splitting.txt](https://github.com/apache/shardingsphere/files/8122477/spring-mysql-readwrite-splitting.txt)
   
   


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

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

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



[GitHub] [shardingsphere] strongduanmu commented on issue #15578: spring JdbcTemplate insert cann't support return key

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


   @larrychen8276 Can you provide your configuration? Besides, you can look at this issue #15451, maybe they are same problems.


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

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

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



[GitHub] [shardingsphere] strongduanmu commented on issue #15578: spring JdbcTemplate insert cann't support return key

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


   Hi @larrychen8276, can you try the latest master branch?


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

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

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



[GitHub] [shardingsphere] larrychen8276 commented on issue #15578: spring JdbcTemplate insert cann't support return key

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


   > @larrychen8276 I think this issue is same with #15451, you can try the latest master branch.
   
   thanks!


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

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

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



[GitHub] [shardingsphere] strongduanmu commented on issue #15578: spring JdbcTemplate insert cann't support return key

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


   @larrychen8276 I think this issue is same with #15451, you can try the latest master branch.


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

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

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