Skip to content

Provide extensibility of query creation [DATAJPA-948] #1299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Aug 9, 2016 · 5 comments
Closed
Assignees
Labels
in: core Issues in core support status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement

Comments

@spring-projects-issues
Copy link

François Lecomte opened DATAJPA-948 and commented

Hi there !
Here is my use case : I need to "inject" some predicates in all JPA queries (security purpose). I succesfully extended SimpleJpaRepository but common CRUD methods, but it's quite tricky when it comes to query methods : PartTreeJpaQuery uses its private QueryPreparer, and doesn't allow extension...
I submitted a PR with few visibility updates, I let you guys have a review and give me feedback about that

thx !


Affects: 1.11 M1 (Ingalls)

Issue Links:

  • DATAJPA-1551 Create an API to customize query creation and query processing

Referenced from: pull request #178

4 votes, 7 watchers

@spring-projects-issues
Copy link
Author

Andreas Gebauer commented

I am also interested in customizing QueryPreparer and CountQueryPreparer. I would really appreciate being able to hook in there

@spring-projects-issues
Copy link
Author

Oliver Drotbohm commented

Would you guys mind to elaborate what you're trying to achieve? Not from a "I want to use this class." point of view but from an end-user feature one

@spring-projects-issues
Copy link
Author

Andreas Gebauer commented

I need to "append" specifications / predicates to each query for security purposes which restricts the results to the users which have the rights to "read" based on some business logic.

I didn't see a way to do this except hooking in directly into the query creation which is encapsulated in these QueryPreparers.

Maybe there is a much more elegant way to do this. I'm very open to suggestions.

 

For the sake of completeness:

I'm currently using the library from the author of this issue https://github.com/lordlothar99/strategy-spring-security-acl which achieves exactly what I want but this library isn't able to customize queries which are using pageables and / or sorting

@spring-projects-issues
Copy link
Author

Andreas Gebauer commented

This issue might be related to DATACMNS-293

@spring-projects-issues
Copy link
Author

Jens Schauder commented

We won't implement this as it currently is proposed.
But I created a separate issue in an attempt to come up with a maintainable API for this kind of stuff: DATAJPA-1551

@spring-projects-issues spring-projects-issues added status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement in: core Issues in core support labels Dec 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core support status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants