From 5701c6c85ae1000a266ba155bf9066010b4c7e35 Mon Sep 17 00:00:00 2001 From: vramik Date: Tue, 8 Feb 2022 13:59:45 +0100 Subject: [PATCH] JPA delegates can throw NoResultException when entity doesn't have any attributes Closes #10067 --- .../storage/jpa/client/delegate/JpaClientDelegateProvider.java | 2 +- .../clientscope/delegate/JpaClientScopeDelegateProvider.java | 2 +- .../map/storage/jpa/role/delegate/JpaRoleDelegateProvider.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/client/delegate/JpaClientDelegateProvider.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/client/delegate/JpaClientDelegateProvider.java index bab3792d6e..5f7c6c9a04 100644 --- a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/client/delegate/JpaClientDelegateProvider.java +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/client/delegate/JpaClientDelegateProvider.java @@ -57,7 +57,7 @@ public class JpaClientDelegateProvider extends JpaDelegateProvider query = cb.createQuery(JpaClientEntity.class); Root root = query.from(JpaClientEntity.class); - root.fetch("attributes", JoinType.INNER); + root.fetch("attributes", JoinType.LEFT); query.select(root).where(cb.equal(root.get("id"), UUID.fromString(getDelegate().getId()))); setDelegate(em.createQuery(query).getSingleResult()); diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/clientscope/delegate/JpaClientScopeDelegateProvider.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/clientscope/delegate/JpaClientScopeDelegateProvider.java index 025a9ad70c..e4883460df 100644 --- a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/clientscope/delegate/JpaClientScopeDelegateProvider.java +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/clientscope/delegate/JpaClientScopeDelegateProvider.java @@ -55,7 +55,7 @@ public class JpaClientScopeDelegateProvider extends JpaDelegateProvider query = cb.createQuery(JpaClientScopeEntity.class); Root root = query.from(JpaClientScopeEntity.class); - root.fetch("attributes", JoinType.INNER); + root.fetch("attributes", JoinType.LEFT); query.select(root).where(cb.equal(root.get("id"), UUID.fromString(getDelegate().getId()))); setDelegate(em.createQuery(query).getSingleResult()); diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/role/delegate/JpaRoleDelegateProvider.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/role/delegate/JpaRoleDelegateProvider.java index dfb41abe10..0ab9b6cfa3 100644 --- a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/role/delegate/JpaRoleDelegateProvider.java +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/role/delegate/JpaRoleDelegateProvider.java @@ -55,7 +55,7 @@ public class JpaRoleDelegateProvider extends JpaDelegateProvider CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery query = cb.createQuery(JpaRoleEntity.class); Root root = query.from(JpaRoleEntity.class); - root.fetch("attributes", JoinType.INNER); + root.fetch("attributes", JoinType.LEFT); query.select(root).where(cb.equal(root.get("id"), UUID.fromString(getDelegate().getId()))); setDelegate(em.createQuery(query).getSingleResult());