diff --git a/src/main/java/org/rciam/plugins/groups/jpa/repositories/MemberUserAttributeConfigurationRepository.java b/src/main/java/org/rciam/plugins/groups/jpa/repositories/MemberUserAttributeConfigurationRepository.java index 7d088d0..4cfe18d 100644 --- a/src/main/java/org/rciam/plugins/groups/jpa/repositories/MemberUserAttributeConfigurationRepository.java +++ b/src/main/java/org/rciam/plugins/groups/jpa/repositories/MemberUserAttributeConfigurationRepository.java @@ -10,7 +10,7 @@ public MemberUserAttributeConfigurationRepository(KeycloakSession session) { } public MemberUserAttributeConfigurationEntity getByRealm(String realmId){ - return em.createNamedQuery("getConfigurationByRealm", MemberUserAttributeConfigurationEntity.class).setParameter("realmId",realmId).getResultStream().findAny().orElse(null); + return em.createNamedQuery("getConfigurationByRealm", MemberUserAttributeConfigurationEntity.class).setParameter("realmId",realmId).getResultStream().findAny().orElse(new MemberUserAttributeConfigurationEntity()); } @Override diff --git a/src/main/java/org/rciam/plugins/groups/scheduled/StartUpTasks.java b/src/main/java/org/rciam/plugins/groups/scheduled/StartUpTasks.java index ea18d27..0c90881 100644 --- a/src/main/java/org/rciam/plugins/groups/scheduled/StartUpTasks.java +++ b/src/main/java/org/rciam/plugins/groups/scheduled/StartUpTasks.java @@ -28,7 +28,7 @@ public void run(KeycloakSession session) { MemberUserAttributeConfigurationRepository memberUserAttributeConfigurationRepository = new MemberUserAttributeConfigurationRepository(session); repository.dailyExecutedActions(session); //create default eduPersonEntitlement configuration entity if not exist - if (memberUserAttributeConfigurationRepository.getByRealm(realm.getId()) == null) { + if (memberUserAttributeConfigurationRepository.getByRealm(realm.getId()).getId() == null) { MemberUserAttributeConfigurationEntity configurationEntity = new MemberUserAttributeConfigurationEntity(); configurationEntity.setId(KeycloakModelUtils.generateId()); configurationEntity.setUserAttribute("eduPersonEntitlement");