Query interceptor for spring-data-mongodb for soft deletions

╄→гoц情女王★ 提交于 2019-12-10 16:53:39

问题


I want to add where condition to all repository fetching methods for not viewing deleted items. In Spring JPA it's possible to add @Where annotation to Entity. But for Spring Data MongoDB AFAIK it's not possible. Tried Mongodb lifecycle events but not succeeded. Is there a way of modifying repository queries before execution.


回答1:


Can you explain what do you mean with "viewing deleted items"? If you want, you can use MongoTemplate and write your own repository and so can add desired where condition to every method



来源:https://stackoverflow.com/questions/43807143/query-interceptor-for-spring-data-mongodb-for-soft-deletions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!