Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
hql-pageable-example.kt
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