Skip to content

Commit

Permalink
chore : using entitygraph instead of joins
Browse files Browse the repository at this point in the history
  • Loading branch information
rajadilipkolli committed Aug 2, 2024
1 parent f7f6b67 commit e0080a9
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.querydsl.core.types.dsl.StringExpression;
import com.querydsl.core.types.dsl.StringPath;
import java.util.List;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
Expand All @@ -23,9 +24,8 @@ default void customize(QuerydslBindings bindings, QPost root) {
bindings.excluding(root.id);
}

@Query(
"select o from Post o left join fetch o.details pd left join fetch o.comments where pd.createdBy = :createdBy")
List<Post> findByDetails_CreatedByEqualsIgnoreCase(@Param("createdBy") String createdBy);
@EntityGraph(attributePaths = {"details", "comments"})
List<Post> findByDetails_CreatedByEqualsIgnoreCase(String createdBy);

@Query("select p from Post p left join fetch p.tags where p in :posts ORDER BY p.id")
List<Post> findAllPostsWithTags(@Param("posts") List<Post> posts);
Expand Down

0 comments on commit e0080a9

Please sign in to comment.