Automatically Add criteria on each Spring Jpa Repository call

无人久伴 提交于 2019-12-07 11:37:35

问题


I'm writing a library that wraps the JpaRepository interface of Spring Data Jpa because I want to add the same criteria automatically to all JpaRepository DB calls (something like and where t > something).

For example findById function of JpaRepository under the hood will be translated to find by id and where t > something

Is it possible? and if so, how do I do it?

Thanks!


回答1:


A long time ago this was planned, but the team came to the conclusion that it really doesn't seem possible to do it properly. So No, the feature does not exist. See here for details: https://jira.spring.io/browse/DATACMNS-293

There is Hibernates @Where and @Filter though.



来源:https://stackoverflow.com/questions/47751564/automatically-add-criteria-on-each-spring-jpa-repository-call

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