Create workaround for "identifier of an instance altered"
Related to: #19323
This commit is contained in:
parent
adb47ac874
commit
ad82252a44
2 changed files with 15 additions and 1 deletions
|
@ -927,7 +927,16 @@ public class JpaUserProvider implements UserProvider, UserCredentialStore {
|
|||
query.setParameter("identityProvider", identityProvider);
|
||||
query.setLockMode(lockMode);
|
||||
List<FederatedIdentityEntity> results = query.getResultList();
|
||||
return results.size() > 0 ? results.get(0) : null;
|
||||
FederatedIdentityEntity federatedIdentityEntity = results.size() > 0 ? results.get(0) : null;
|
||||
if (federatedIdentityEntity != null) {
|
||||
// When upgrading from Hibernate 5 to Hibernate 6.2.0.CR3, the `user` wasn't filled in the returned row any more.
|
||||
// This serves as a workaround until the cause has been found and the upstream project can provide a fix
|
||||
// https://github.com/keycloak/keycloak/issues/19323
|
||||
if (federatedIdentityEntity.getUser() == null) {
|
||||
federatedIdentityEntity.setUser(userEntity);
|
||||
}
|
||||
}
|
||||
return federatedIdentityEntity;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -156,6 +156,11 @@ public class FederatedIdentityEntity {
|
|||
result = 31 * result + (identityProvider != null ? identityProvider.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FederatedIdentityEntity.Key [user=" + (user != null ? user.getId() : null) + ", identityProvider=" + identityProvider + "]";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue