Skip to content

Add Projections to QuerydslPredicateExecutor #3159

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
membersound opened this issue Sep 13, 2023 · 4 comments
Closed

Add Projections to QuerydslPredicateExecutor #3159

membersound opened this issue Sep 13, 2023 · 4 comments
Labels
status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged

Comments

@membersound
Copy link

membersound commented Sep 13, 2023

It would be great if the findBy() method of QuerydslPredicateExecutor could support projection interfaces.

The method currently only works with the real @Entity, like:

intercace MyEntityRepository extends JpaRepository<MyEntity, Long>, QuerydslPredicateExecutor<MyEntity> {
}

Usage:

Stream<MyEntity> stream = dao.findBy(predicate, FluentQuery.FetchableFluentQuery::stream);

But not this:

Stream<MyEntityView> stream = dao.findBy(predicate, FluentQuery.FetchableFluentQuery::stream)
interface MyEntityView {
     String getMyField1();
     String getMyField4();
}
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 13, 2023
@mp911de
Copy link
Member

mp911de commented Sep 13, 2023

Have you seen that findBy accepts a functional callback that lets you specify the target type?

dao.findBy(predicate, q -> q.as(MyEntityView.class).stream())

@mp911de mp911de added the status: waiting-for-feedback We need additional information before we can continue label Sep 13, 2023
@membersound
Copy link
Author

I see, yes that's what I was looking for. Maybe this could be added to the docs? I could not find such an example.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Sep 14, 2023
@mp911de
Copy link
Member

mp911de commented Sep 14, 2023

@membersound
Copy link
Author

So as my ticket is about how to use projections, I think this is answered sufficient.

Anyways there seems to be a performance issue with this approach, for which I created a new issue for better tracking:
#3160

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

No branches or pull requests

3 participants