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.
Asked
Active
Viewed 898 times
4
-
Hey, any updates on this? I'm also facing this problem. – Hienz Jun 27 '19 at 12:38
-
As I see, ticket https://jira.spring.io/browse/DATAMONGO-1692 was created, although no feedback from Spring Data Mongodb team. – heroin Nov 11 '19 at 14:04
1 Answers
0
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

barbakini
- 3,024
- 2
- 19
- 25
-
Yes it's possible to add is_deleted where condition to every single method. But I try to find a shortcut. You can find the derails for where annotation: https://docs.jboss.org/hibernate/stable/annotations/reference/en/html_single/#entity-hibspec-collection and related stackoverflow answer: http://stackoverflow.com/a/22202469/159837 BTW If you want me to clarify question you can use comment section instead of answer. – Fırat Küçük May 06 '17 at 06:24