Skip to content

Commit 6f803d9

Browse files
committed
feature: optimised UserRepository queries
1 parent 6f738b8 commit 6f803d9

1 file changed

Lines changed: 0 additions & 24 deletions

File tree

rentplace/src/main/java/kattsyn/dev/rentplace/repositories/UserRepository.java

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,43 +14,19 @@ public interface UserRepository extends JpaRepository<User, Long> {
1414
@Query("""
1515
SELECT DISTINCT u FROM User u
1616
LEFT JOIN FETCH u.image
17-
LEFT JOIN FETCH u.favourites f
18-
LEFT JOIN FETCH f.categories c
19-
LEFT JOIN FETCH f.facilities fac
20-
LEFT JOIN FETCH f.owner o
21-
LEFT JOIN FETCH f.images
22-
LEFT JOIN FETCH c.image
23-
LEFT JOIN FETCH fac.image
24-
LEFT JOIN FETCH o.image
2517
""")
2618
List<User> findAllWithRelations();
2719

2820
@Query("""
2921
SELECT DISTINCT u FROM User u
3022
LEFT JOIN FETCH u.image
31-
LEFT JOIN FETCH u.favourites f
32-
LEFT JOIN FETCH f.categories c
33-
LEFT JOIN FETCH f.facilities fac
34-
LEFT JOIN FETCH f.owner o
35-
LEFT JOIN FETCH f.images
36-
LEFT JOIN FETCH c.image
37-
LEFT JOIN FETCH fac.image
38-
LEFT JOIN FETCH o.image
3923
WHERE u.userId = :userId
4024
""")
4125
Optional<User> findById(@Param("userId") long userId);
4226

4327
@Query("""
4428
SELECT DISTINCT u FROM User u
4529
LEFT JOIN FETCH u.image
46-
LEFT JOIN FETCH u.favourites f
47-
LEFT JOIN FETCH f.categories c
48-
LEFT JOIN FETCH f.facilities fac
49-
LEFT JOIN FETCH f.owner o
50-
LEFT JOIN FETCH f.images
51-
LEFT JOIN FETCH c.image
52-
LEFT JOIN FETCH fac.image
53-
LEFT JOIN FETCH o.image
5430
WHERE u.email = :email
5531
""")
5632
Optional<User> findByEmail(@Param("email") String email);

0 commit comments

Comments
 (0)