From 1c743a269ff70822cdfa59d4f3ce55cbd2434bdd Mon Sep 17 00:00:00 2001 From: Okke Harsta Date: Fri, 20 Dec 2024 11:22:18 +0100 Subject: [PATCH] Generated SQL by Spring explicitely converts enum values --- server/src/main/java/access/api/InvitationController.java | 4 ++-- .../main/java/access/repository/InvitationRepository.java | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/server/src/main/java/access/api/InvitationController.java b/server/src/main/java/access/api/InvitationController.java index 8884c4c..88f7b02 100644 --- a/server/src/main/java/access/api/InvitationController.java +++ b/server/src/main/java/access/api/InvitationController.java @@ -144,7 +144,7 @@ public ResponseEntity getInvitation(@RequestParam("hash") String has public ResponseEntity> all(@Parameter(hidden = true) User user) { LOG.debug("/all invitations"); UserPermissions.assertAuthority(user, Authority.SUPER_USER); - return ResponseEntity.ok(invitationRepository.findByStatus(Status.OPEN.name())); + return ResponseEntity.ok(invitationRepository.findByStatus(Status.OPEN)); } @@ -313,7 +313,7 @@ public ResponseEntity> byRole(@PathVariable("roleId") Long role Role role = roleRepository.findById(roleId).orElseThrow(() -> new NotFoundException("Role not found")); UserPermissions.assertRoleAccess(user, role, Authority.INVITER); - List invitations = invitationRepository.findByStatusAndRoles_role(Status.OPEN.name(), role); + List invitations = invitationRepository.findByStatusAndRoles_role(Status.OPEN, role); return ResponseEntity.ok(invitations); } diff --git a/server/src/main/java/access/repository/InvitationRepository.java b/server/src/main/java/access/repository/InvitationRepository.java index 7f1bb9e..8d692d5 100644 --- a/server/src/main/java/access/repository/InvitationRepository.java +++ b/server/src/main/java/access/repository/InvitationRepository.java @@ -2,6 +2,7 @@ import access.model.Invitation; import access.model.Role; +import access.model.Status; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; @@ -24,9 +25,9 @@ public interface InvitationRepository extends JpaRepository, Q Optional findTopBySubInviteeOrderByCreatedAtDesc(String email); - List findByStatus(String status); + List findByStatus(Status status); - List findByStatusAndRoles_role(String status, Role role); + List findByStatusAndRoles_role(Status status, Role role); @Query(value = """ SELECT i.id, i.email, i.intended_authority,i.created_at, i.expiry_date,