From 020dd530b9333a98d29aa9866e3cf7ac40514732 Mon Sep 17 00:00:00 2001 From: vramik Date: Wed, 5 May 2021 16:29:12 +0200 Subject: [PATCH] KEYCLOAK-18009 Invalid role creation with oracle database --- .../src/main/java/org/keycloak/models/jpa/JpaRealmProvider.java | 2 +- .../main/java/org/keycloak/models/jpa/entities/RoleEntity.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/JpaRealmProvider.java b/model/jpa/src/main/java/org/keycloak/models/jpa/JpaRealmProvider.java index 9bbed5d148..7e4c9d93e7 100644 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/JpaRealmProvider.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/JpaRealmProvider.java @@ -245,9 +245,9 @@ public class JpaRealmProvider implements RealmProvider, ClientProvider, ClientSc RoleEntity roleEntity = new RoleEntity(); roleEntity.setId(id); roleEntity.setName(name); + roleEntity.setRealmId(client.getRealm().getId()); roleEntity.setClientId(client.getId()); roleEntity.setClientRole(true); - roleEntity.setRealmId(client.getRealm().getId()); em.persist(roleEntity); RoleAdapter adapter = new RoleAdapter(session, client.getRealm(), em, roleEntity); return adapter; diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RoleEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RoleEntity.java index 74c0714272..c77ae0ca61 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RoleEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RoleEntity.java @@ -115,6 +115,7 @@ public class RoleEntity { public void setRealmId(String realmId) { this.realmId = realmId; + this.clientRealmConstraint = realmId; } public List getAttributes() {