spring-data-jpa icon indicating copy to clipboard operation
spring-data-jpa copied to clipboard

Allow to inject further conditions for Queries generated from JpaRepository method Names [DATAJPA-1646]

Open spring-projects-issues opened this issue 6 years ago • 2 comments

Julian opened DATAJPA-1646 and commented

I have a large set of entities that share common fields and multiple queries that I want to constrain on it.

As Example consider a field "deleted" which tracks if the Entity should be shown to the user or is "delteted". I would like to always get the additional Condition "deleted = false" on my Queries that are generated from the JpaRepositories Method Names.

From my research it seems like this would be doable by injecting a Custom CreateQueryLookupStrategy or modyfing the PartTree in the PartTreeJpaQuery Class. From the Current structure of the code this is not doable (without massive hacking) but it would be nice to get some kind of extension to the API to allow such modifications.

 

Related Stackoverflow post: https://stackoverflow.com/questions/59283251/inject-further-query-conditions-inject-automatic-entity-field-values-when-usin

Related Issue DATAJPA-1551


No further details from DATAJPA-1646

spring-projects-issues avatar Dec 12 '19 10:12 spring-projects-issues

Muhammad Sufyian commented

Jens Schauder are you working on this issue ? I want to take it ? 

 

spring-projects-issues avatar Mar 01 '20 21:03 spring-projects-issues

Jens Schauder commented

I'm not working on this, nor is anyone else. But it is also not clear if we want this feature and if so in what form. I therefore currently recommend against working on it

spring-projects-issues avatar Mar 02 '20 07:03 spring-projects-issues

I don't think opening one aspect of the JpaQueryLookupStrategy to injection of what is currently a private inner class is a good strategy.

It introduces too many risks with not enough benefit. To top things off, the linked SO post has actually been removed for moderations reasons.

If you have a bigger vision of what a customizable query system would be, I would suggest opening a ticket to lay that out so we can analyze if that's suitable. In this current setup, this isn't something we want to take up.

gregturn avatar Aug 10 '23 16:08 gregturn