Skip to content

Commit

Permalink
PI-1686 Case-insensitive username lookup (#2733)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-bcl authored Nov 24, 2023
1 parent e16b8a3 commit 086d16a
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,23 @@ package uk.gov.justice.digital.hmpps.repository

import org.springframework.data.jpa.repository.EntityGraph
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Query
import uk.gov.justice.digital.hmpps.entity.StaffEntity

interface StaffRepository : JpaRepository<StaffEntity, Long> {
@EntityGraph(attributePaths = ["user", "teams.district.borough"])
fun findByCode(code: String): StaffEntity?

@EntityGraph(attributePaths = ["user", "teams.district.borough"])
@Query(
"""
select s from StaffEntity s
join fetch s.user u
left join fetch s.teams t
left join fetch t.district d
left join fetch d.borough
where upper(u.username) = upper(:username)
"""
)
fun findByUserUsername(username: String): StaffEntity?

@EntityGraph(attributePaths = ["user", "teams.district.borough"])
Expand Down

0 comments on commit 086d16a

Please sign in to comment.