Repository method defines a LEFT JOIN, as we need to sort on something in role, but it is an optional foreign key.
@Query("""
SELECT ak FROM ApiKey ak
LEFT JOIN ak.role r
WHERE ak.projectId = :projectId
""")
Page<ApiKey> find(@Param("projectId") UUID projectId, Pageable pageable);
Generated SQL creates a regular JOIN now, which means results go missing.
Hibernate: select a1_0.id,a1_0.created_date,a1_0.db_version,a1_0.expiry_date,a1_0.last_used,a1_0.name,a1_0.project_id,a1_0.public_part,a1_0.role_id,a1_0.secret_key_hash,a1_0.updated_date from api_key a1_0 join role r2_0 on r2_0.id=a1_0.role_id where a1_0.project_id=? order by r2_0.name offset ? rows fetch first ? rows only