Skip to content

Commit

Permalink
Generated SQL by Spring explicitely converts enum values
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Dec 20, 2024
1 parent 7c116a3 commit 1c743a2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions server/src/main/java/access/api/InvitationController.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public ResponseEntity<Invitation> getInvitation(@RequestParam("hash") String has
public ResponseEntity<List<Invitation>> 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));
}


Expand Down Expand Up @@ -313,7 +313,7 @@ public ResponseEntity<List<Invitation>> byRole(@PathVariable("roleId") Long role

Role role = roleRepository.findById(roleId).orElseThrow(() -> new NotFoundException("Role not found"));
UserPermissions.assertRoleAccess(user, role, Authority.INVITER);
List<Invitation> invitations = invitationRepository.findByStatusAndRoles_role(Status.OPEN.name(), role);
List<Invitation> invitations = invitationRepository.findByStatusAndRoles_role(Status.OPEN, role);
return ResponseEntity.ok(invitations);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -24,9 +25,9 @@ public interface InvitationRepository extends JpaRepository<Invitation, Long>, Q

Optional<Invitation> findTopBySubInviteeOrderByCreatedAtDesc(String email);

List<Invitation> findByStatus(String status);
List<Invitation> findByStatus(Status status);

List<Invitation> findByStatusAndRoles_role(String status, Role role);
List<Invitation> findByStatusAndRoles_role(Status status, Role role);

@Query(value = """
SELECT i.id, i.email, i.intended_authority,i.created_at, i.expiry_date,
Expand Down

0 comments on commit 1c743a2

Please sign in to comment.