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/09/17 08:59:54 UTC

[GitHub] [shardingsphere] zengpeng5281314 opened a new issue, #21035: sharding sql rewrite error

zengpeng5281314 opened a new issue, #21035:
URL: https://github.com/apache/shardingsphere/issues/21035

   ## Bug Report
   
   ### Which version of ShardingSphere did you use?
   shardingsphere 5.1.2
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-JDBC 
   ### Expected behavior
   execute jpa sql
   
   @Modifying(clearAutomatically = true,flushAutomatically = true)
   	@Transactional
   	@Query(value="update mail_label set label_name = :labelName ,label_color = :labelColor, update_user_id = :updateUserId,update_user_name = :updateUserName,update_time = :updateTime where org_id = :orgId and user_id = :userId and id in( :id )", nativeQuery = true)
   	int upLabelNameAndColorByOrgUserAndId(@Param("orgId") Integer orgId, @Param("userId") Integer userId, @Param("id") Long id, @Param("labelName") String labelName, @Param("labelColor") String labelColor, @Param("updateUserId") String updateUserId, @Param("updateUserName") String updateUserName,@Param("updateTime") Date updateTime);
   
   ### Actual behavior
   the logicSQL sql show 
   update mail_label set create_time=?, create_user_id=?, is_delete=?, label_color=?, label_name=?, label_sort=?, org_id=?, update_time=?, update_user_id=?, user_id=? where id=?
   
   ### Reason analyze (If you can)
   maybe spring.jpa.open-in-view the reason
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   When I request the interface through the id, I first query the entity through the id, and then execute the update, and the update logic sql reports an error!
   
   When I junittest the findMailLabelById and upLabelNameAndColorByOrgUserAndId, it is working right! So,I don't know what happened!
   
   shardingkey: 
          databasekey: orgid%10
          tablekey:user_id%50
   
   @Query(value="select * from mail_label where org_id = :orgId and user_id = :userId and id = :id ", nativeQuery = true)
   	MailLabel findMailLabelById(@Param("orgId") Integer orgId, @Param("userId") Integer userId, @Param("id") Long id);
   
   	@Modifying(clearAutomatically = true,flushAutomatically = true)
   	@Transactional
   	@Query(value="update mail_label set label_name = :labelName ,label_color = :labelColor, update_user_id = :updateUserId,update_user_name = :updateUserName,update_time = :updateTime where org_id = :orgId and user_id = :userId and id in( :id )", nativeQuery = true)
   	int upLabelNameAndColorByOrgUserAndId(@Param("orgId") Integer orgId, @Param("userId") Integer userId, @Param("id") Long id, @Param("labelName") String labelName, @Param("labelColor") String labelColor, @Param("updateUserId") String updateUserId, @Param("updateUserName") String updateUserName,@Param("updateTime") Date updateTime);
   
   
   ### Example codes for reproduce this issue (such as a github link).
   
   
   public Result<Object> updateMailLabel(UpdateMailLabelCondition updateMailLabelCondition)
   			throws Exception {
   		try {
   			MailLabel mailLabel = mailLabelRepository.findMailLabelById(NumberUtils.toInt(updateMailLabelCondition.getOrgId()),
   					NumberUtils.toInt(updateMailLabelCondition.getUpdateUserId()),updateMailLabelCondition.getId());
   			if(mailLabel != null) {
   				BeanUtils.copyProperties(mailLabel,updateMailLabelCondition);
   				mailLabel.setUpdateTime(new Date());
   				int count= mailLabelRepository.upLabelNameAndColorByOrgUserAndId(NumberUtils.toInt(updateMailLabelCondition.getOrgId()),
   NumberUtils.toInt(updateMailLabelCondition.getUpdateUserId()),updateMailLabelCondition.getId(),updateMailLabelCondition.getLabelName(),updateMailLabelCondition.getLabelColor(),updateMailLabelCondition.getUpdateUserId(),updateMailLabelCondition.getUpdateUserName(),new Date());
   updateMailLabelCondition.getUpdateUserId(),updateMailLabelCondition.getUpdateUserName(),new Date());
   				if(count<1){
   					return ResultUtil.error(0, "更新失败!!!");
   				}
   				return ResultUtil.success(1, "修改成功!!!", mailLabel);
   			}else {
   				return ResultUtil.error(0, "修改失败!!!修改对象不存在!!!");
   			}
   		} catch (Exception e) {
   			e.printStackTrace();
   			return ResultUtil.error(0, "修改失败!!!");
   		}
   	}
   


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

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


[GitHub] [shardingsphere] github-actions[bot] commented on issue #21035: sharding sql rewrite error

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on issue #21035:
URL: https://github.com/apache/shardingsphere/issues/21035#issuecomment-1272348396

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


-- 
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] github-actions[bot] closed issue #21035: sharding sql rewrite error

Posted by GitBox <gi...@apache.org>.
github-actions[bot] closed issue #21035: sharding sql rewrite error
URL: https://github.com/apache/shardingsphere/issues/21035


-- 
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] RaigorJiang closed issue #21035: sharding sql rewrite error

Posted by "RaigorJiang (via GitHub)" <gi...@apache.org>.
RaigorJiang closed issue #21035: sharding sql rewrite error
URL: https://github.com/apache/shardingsphere/issues/21035


-- 
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] RaigorJiang commented on issue #21035: sharding sql rewrite error

Posted by "RaigorJiang (via GitHub)" <gi...@apache.org>.
RaigorJiang commented on issue #21035:
URL: https://github.com/apache/shardingsphere/issues/21035#issuecomment-1407629911

   This issue has been inactive for a long time, and ShardingSphere has released several new versions, so I will close it.
   Please try the latest version, and if the problem reproduces, please reopen it or submit a new one.


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