Closed aftabshk closed 1 week ago
Spring Data JPA is not in charge of generating SQL from JPQL. How would you even express such a query in JPQL?
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.
I am using following versions:
PostgresSQL - 14.5 Spring Boot - 3.1.11 Spring Data Jpa - 3.1.11
I have two Entity classes like below:
I want to perform a distinct query based on a particular column like below. In postgres this gives me rows by performing a distinct only on id column.
select distinct on (q.id) q.id, q.quote, q.author_id, a.name from quote q join author a on q.id = a.id
I have tried two ways so far:
But this will create a query like below which is not what I require. This query applies distinct over all the projections
select distinct q.id, q.quote, q.author_id, a.name from quote q join author a on q.type = ?
This will also create a query like below which is not what I require:
select distinct q.id, q.quote, q.author_id, a.name from quote q join author a on q.type = ?
Is there any way to do this? Something like below:
findDistinctOnByType("id", "type")
.Or please suggest if there's any other workaround