You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When writing a QueryDSL query as demonstrated in the provided code snippet, it's observed that the WHERE clause related to filtering comments based on the delete_yn = 'N' condition is being duplicated in the generated SQL query. This duplication results in an unnecessary repetition of the same condition, as shown in the Hibernate log output:
@Test@DisplayName("querydsl with where fetch join")
voidquerydsl_with_where_fetch_join() {
jpaQueryFactory.selectFrom(board)
.leftJoin(board.comment, comment).fetchJoin()
.fetch();
}
The expected behavior would be for the WHERE clause to apply the condition only once, ensuring efficient and accurate query execution. However, the observed behavior shows the condition (c1_0.delete_yn = 'N') being applied twice in the SQL query:
Hibernate: select b1_0.id,c1_0.board_id,c1_0.id,c1_0.content,c1_0.delete_yn,b1_0.content,b1_0.title from board b1_0 left join comment c1_0 on b1_0.id=c1_0.board_id and (c1_0.delete_yn = 'N') and (c1_0.delete_yn = 'N')
This issue highlights a potential inefficiency in the query construction process when using QueryDSL with a fetch join, leading to the duplication of WHERE clause conditions.
Observed vs. expected behavior
When writing a QueryDSL query as demonstrated in the provided code snippet, it's observed that the WHERE clause related to filtering comments based on the
delete_yn = 'N'
condition is being duplicated in the generated SQL query. This duplication results in an unnecessary repetition of the same condition, as shown in the Hibernate log output:The expected behavior would be for the WHERE clause to apply the condition only once, ensuring efficient and accurate query execution. However, the observed behavior shows the condition
(c1_0.delete_yn = 'N')
being applied twice in the SQL query:This issue highlights a potential inefficiency in the query construction process when using QueryDSL with a fetch join, leading to the duplication of WHERE clause conditions.
Steps to reproduce
https://github.com/HDPark95/querydsl-issue
package my.example.querydslissue.querydsl;
querydsl_with_where_fetch_join
method make this issue
Environment
Querydsl version: 5.0.0:jakarta
Database: h2
JDK: 17
spring boot 3.0.1
Additional details
The text was updated successfully, but these errors were encountered: