-
-
Save Senorsen/edd0fb0306fbc022be5f636eeb9c9736 to your computer and use it in GitHub Desktop.
hql-pageable-example.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface EmployeeDao : JpaRepository<Employee, Long> { | |
// ... | |
// 如果对应 Entity 字段有 eager fetch | |
fun findByCompanyId(companyId: Long, pageable: Pageable): Page<Employee> | |
// 如果对应 Entity 字段无 eager fetch | |
@Query("""FROM Employee e | |
JOIN FETCH e.department d | |
JOIN FETCH d.parent pd | |
WHERE e.companyId = :companyId | |
""") | |
fun findByCompanyId(companyId: Long, pageable: Pageable): Page<Employee> | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment