Replies: 3 comments
-
Just use a JPQL query and create a custom function for the "ROW_NUMBER" function. You can also use JPASQLFunctions only serve a very specific use case and I doubt that associtation joins are supported. |
Beta Was this translation helpful? Give feedback.
-
@jwgmeligmeyling |
Beta Was this translation helpful? Give feedback.
-
Seems to have found a way. @Override
public void mySolution() {
QSummoner summoner = QSummoner.summoner;
QMatch match = QMatch.match;
// Create Qclass for @JoinTable
QSummoner summoner_match1 = new QSummoner("summoner_match");
QMatch summoner_match2 = new QMatch("summoner_match");
jpasqlQuery
.select(summoner, match, SQLExpressions.rowNumber().over())
.from(summoner)
.leftJoin(summoner_match1).on(summoner.accountId.eq(summoner_match1.accountId))
.leftJoin(match).on(summoner_match2.gameId.eq(match.gameId))
.fetch();
} |
Beta Was this translation helpful? Give feedback.
-
For example, when the source code is as follows
I want to generate the following sql using JPASQLQuery class
I tried and failed like below.
(Please tell me if there is any other method provided by querydsl other than using the JPASQLQuery class.)
Beta Was this translation helpful? Give feedback.
All reactions