Skip to content

Commit 42a0461

Browse files
committed
using jpql
1 parent 583a148 commit 42a0461

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
package com.example.so69762445;
22

3+
import java.util.List;
34
import org.springframework.data.jpa.repository.JpaRepository;
5+
import org.springframework.data.jpa.repository.Query;
46

57
public interface ARepository extends CustomizedARepository, JpaRepository<A, Long> {
8+
9+
@Query("select distinct a from A a left join fetch a.bs")
10+
List<A> getAllJpqlFetch();
611
}

so69762445/src/main/java/com/example/so69762445/MyController.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,9 @@ public List<A> jpa() {
3434
public List<A> criteria() {
3535
return repo.getAllCriteria();
3636
}
37+
38+
@GetMapping("/jpql")
39+
public List<A> jpql() {
40+
return repo.getAllJpqlFetch();
41+
}
3742
}

0 commit comments

Comments
 (0)