Ron Badur
Ron Badur

Reputation: 1963

Automatically Add criteria on each Spring Jpa Repository call

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!

Upvotes: 5

Views: 1101

Answers (1)

Jens Schauder
Jens Schauder

Reputation: 81907

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.

Upvotes: 2

Related Questions