Automatically Add criteria on each Spring Jpa Repo

2019-05-07 11:22发布

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条回答
戒情不戒烟
2楼-- · 2019-05-07 11:50

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.

查看更多
登录 后发表回答