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/01/23 02:28:16 UTC

[GitHub] [shardingsphere] yage-czy removed a comment on issue #14949: how to use CrudRepository.save of jpa?i dont want my sql route to all data node

yage-czy removed a comment on issue #14949:
URL: https://github.com/apache/shardingsphere/issues/14949#issuecomment-1018472864


   **方案一 -> 使用JPA的EmptyInterceptor**
   
   - insert : sharding可天然支持
   - select : sharding可天然支持
   - update : 继承org.hibernate.EmptyInterceptor,在onPrepareStatement(String sql)方法中,对sql进行解析,获取其中的分片键,然后手动在sql语句后面拼接字符串" and 分片键 = 获取到的分片值",即可实现
   - delete : 使用@Query注解手动写delete语句,需要注意的是原始的"SimpleJpaRepository.delete"方法不能再使用,否则同样会发生路由到所有数据节点的问题


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