From 3111ef008554f1f4c83887fad1c6a0d163be77b1 Mon Sep 17 00:00:00 2001 From: Stefan Guilhen Date: Fri, 6 Jan 2023 11:18:29 -0300 Subject: [PATCH] Map Storage JPA fixes --- Quarkus3 branch sync no. 6 (17.2.2023) Resolved conflicts: keycloak/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/JpaMapStorageProviderFactory.java - Modified --- Quarkus3 branch sync no. 3 (27.1.2023) Resolved conflicts: keycloak/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/JpaMapStorageProviderFactory.java - Modified --- .../jpa/JpaMapStorageProviderFactory.java | 8 +--- .../JpaAuthenticationSessionMetadata.java | 3 ++ .../JpaRootAuthenticationSessionMetadata.java | 3 ++ .../entity/JpaPermissionMetadata.java | 2 + .../policy/entity/JpaPolicyMetadata.java | 2 + .../resource/entity/JpaResourceMetadata.java | 2 + .../entity/JpaResourceServerMetadata.java | 2 + .../scope/entity/JpaScopeMetadata.java | 2 + .../jpa/client/entity/JpaClientMetadata.java | 2 + .../entity/JpaClientScopeMetadata.java | 2 + .../admin/entity/JpaAdminEventMetadata.java | 3 ++ .../auth/entity/JpaAuthEventMetadata.java | 3 ++ .../jpa/group/entity/JpaGroupMetadata.java | 2 + .../JsonbMetadataBuilderContributor.java | 39 +++++++++++++++++++ .../jpa/hibernate/jsonb/JsonbType.java | 5 +++ .../entity/JpaUserLoginFailureMetadata.java | 3 ++ .../realm/entity/JpaComponentMetadata.java | 3 ++ .../jpa/realm/entity/JpaRealmMetadata.java | 2 + .../jpa/role/entity/JpaRoleMetadata.java | 2 + .../entity/JpaSingleUseObjectMetadata.java | 3 ++ .../user/entity/JpaUserConsentMetadata.java | 3 ++ .../JpaUserFederatedIdentityMetadata.java | 3 ++ .../jpa/user/entity/JpaUserMetadata.java | 3 ++ .../entity/JpaClientSessionMetadata.java | 2 + .../entity/JpaUserSessionMetadata.java | 2 + .../resources/default-map-jpa-persistence.xml | 5 ++- 26 files changed, 104 insertions(+), 7 deletions(-) create mode 100644 model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/hibernate/jsonb/JsonbMetadataBuilderContributor.java diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/JpaMapStorageProviderFactory.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/JpaMapStorageProviderFactory.java index fca6b33356..997b72ffc5 100644 --- a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/JpaMapStorageProviderFactory.java +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/JpaMapStorageProviderFactory.java @@ -412,6 +412,8 @@ public class JpaMapStorageProviderFactory implements properties.put("hibernate.show_sql", config.getBoolean("showSql", false)); properties.put("hibernate.format_sql", config.getBoolean("formatSql", true)); properties.put("hibernate.dialect", config.get("driverDialect")); + // metadata contributor to register the json type + properties.put("hibernate.metadata_builder_contributor", "org.keycloak.models.map.storage.jpa.hibernate.jsonb.JsonbMetadataBuilderContributor"); Long lockTimeout = config.getLong("lockTimeout", DEFAULT_LOCK_TIMEOUT); if (lockTimeout >= 0) { // This property does not work for PostgreSQL/CockroachDB - https://hibernate.atlassian.net/browse/HHH-16181 @@ -423,12 +425,6 @@ public class JpaMapStorageProviderFactory implements // Pass on the property to 'EventListenerIntegrator' to activate the necessary event listeners for JPA map storage properties.put(EventListenerIntegrator.JPA_MAP_STORAGE_ENABLED, Boolean.TRUE.toString()); - // register custom jsonb type - ServiceRegistry standardRegistry = new StandardServiceRegistryBuilder().build(); - MetadataSources sources = new MetadataSources(standardRegistry); - MetadataBuilder metadataBuilder = sources.getMetadataBuilder(); - metadataBuilder.applyBasicType(JsonbType.INSTANCE); - logger.trace("Creating EntityManagerFactory"); ParsedPersistenceXmlDescriptor descriptor = PersistenceXmlParser.locateIndividualPersistenceUnit( JpaMapStorageProviderFactory.class.getClassLoader() diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/authSession/entity/JpaAuthenticationSessionMetadata.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/authSession/entity/JpaAuthenticationSessionMetadata.java index 3484863e73..acf95276c9 100644 --- a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/authSession/entity/JpaAuthenticationSessionMetadata.java +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/authSession/entity/JpaAuthenticationSessionMetadata.java @@ -39,4 +39,7 @@ public class JpaAuthenticationSessionMetadata extends MapAuthenticationSessionEn public void setEntityVersion(Integer entityVersion) { this.entityVersion = entityVersion; } + + private String metadataClass = this.getClass().getCanonicalName(); + } diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/authSession/entity/JpaRootAuthenticationSessionMetadata.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/authSession/entity/JpaRootAuthenticationSessionMetadata.java index 9c01e42649..c954c0245e 100644 --- a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/authSession/entity/JpaRootAuthenticationSessionMetadata.java +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/authSession/entity/JpaRootAuthenticationSessionMetadata.java @@ -39,4 +39,7 @@ public class JpaRootAuthenticationSessionMetadata extends MapRootAuthenticationS public void setEntityVersion(Integer entityVersion) { this.entityVersion = entityVersion; } + + private String metadataClass = this.getClass().getCanonicalName(); + } diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/authorization/permission/entity/JpaPermissionMetadata.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/authorization/permission/entity/JpaPermissionMetadata.java index c5358f2df1..bf6fcc9b92 100644 --- a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/authorization/permission/entity/JpaPermissionMetadata.java +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/authorization/permission/entity/JpaPermissionMetadata.java @@ -40,4 +40,6 @@ public class JpaPermissionMetadata extends MapPermissionTicketEntityImpl impleme this.entityVersion = entityVersion; } + private String metadataClass = this.getClass().getCanonicalName(); + } diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/authorization/policy/entity/JpaPolicyMetadata.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/authorization/policy/entity/JpaPolicyMetadata.java index f22b349430..a3117b70c9 100644 --- a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/authorization/policy/entity/JpaPolicyMetadata.java +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/authorization/policy/entity/JpaPolicyMetadata.java @@ -40,4 +40,6 @@ public class JpaPolicyMetadata extends MapPolicyEntityImpl implements Serializab this.entityVersion = entityVersion; } + private String metadataClass = this.getClass().getCanonicalName(); + } diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/authorization/resource/entity/JpaResourceMetadata.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/authorization/resource/entity/JpaResourceMetadata.java index 24071e1961..7aa0eb04e8 100644 --- a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/authorization/resource/entity/JpaResourceMetadata.java +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/authorization/resource/entity/JpaResourceMetadata.java @@ -40,4 +40,6 @@ public class JpaResourceMetadata extends MapResourceEntityImpl implements Serial this.entityVersion = entityVersion; } + private String metadataClass = this.getClass().getCanonicalName(); + } diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/authorization/resourceServer/entity/JpaResourceServerMetadata.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/authorization/resourceServer/entity/JpaResourceServerMetadata.java index 3b969c0cf3..a36046eb26 100644 --- a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/authorization/resourceServer/entity/JpaResourceServerMetadata.java +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/authorization/resourceServer/entity/JpaResourceServerMetadata.java @@ -40,4 +40,6 @@ public class JpaResourceServerMetadata extends MapResourceServerEntityImpl imple this.entityVersion = entityVersion; } + private String metadataClass = this.getClass().getCanonicalName(); + } diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/authorization/scope/entity/JpaScopeMetadata.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/authorization/scope/entity/JpaScopeMetadata.java index fbfdd976d5..eaf1d41a7e 100644 --- a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/authorization/scope/entity/JpaScopeMetadata.java +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/authorization/scope/entity/JpaScopeMetadata.java @@ -40,4 +40,6 @@ public class JpaScopeMetadata extends MapScopeEntityImpl implements Serializable this.entityVersion = entityVersion; } + private String metadataClass = this.getClass().getCanonicalName(); + } diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/client/entity/JpaClientMetadata.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/client/entity/JpaClientMetadata.java index 07ac31dbda..5e41e5539b 100644 --- a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/client/entity/JpaClientMetadata.java +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/client/entity/JpaClientMetadata.java @@ -40,4 +40,6 @@ public class JpaClientMetadata extends MapClientEntityImpl implements Serializab this.entityVersion = entityVersion; } + private String metadataClass = this.getClass().getCanonicalName(); + } diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/clientScope/entity/JpaClientScopeMetadata.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/clientScope/entity/JpaClientScopeMetadata.java index 2a07a55f49..aeccdeea81 100644 --- a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/clientScope/entity/JpaClientScopeMetadata.java +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/clientScope/entity/JpaClientScopeMetadata.java @@ -40,4 +40,6 @@ public class JpaClientScopeMetadata extends MapClientScopeEntityImpl implements this.entityVersion = entityVersion; } + private String metadataClass = this.getClass().getCanonicalName(); + } diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/event/admin/entity/JpaAdminEventMetadata.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/event/admin/entity/JpaAdminEventMetadata.java index 8a5894eb64..a342207ed2 100644 --- a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/event/admin/entity/JpaAdminEventMetadata.java +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/event/admin/entity/JpaAdminEventMetadata.java @@ -45,4 +45,7 @@ public class JpaAdminEventMetadata extends MapAdminEventEntityImpl implements Se public void setEntityVersion(Integer entityVersion) { this.entityVersion = entityVersion; } + + private String metadataClass = this.getClass().getCanonicalName(); + } diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/event/auth/entity/JpaAuthEventMetadata.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/event/auth/entity/JpaAuthEventMetadata.java index 9054a8ad65..7494b759ea 100644 --- a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/event/auth/entity/JpaAuthEventMetadata.java +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/event/auth/entity/JpaAuthEventMetadata.java @@ -45,4 +45,7 @@ public class JpaAuthEventMetadata extends MapAuthEventEntityImpl implements Seri public void setEntityVersion(Integer entityVersion) { this.entityVersion = entityVersion; } + + private String metadataClass = this.getClass().getCanonicalName(); + } diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/group/entity/JpaGroupMetadata.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/group/entity/JpaGroupMetadata.java index baa8025b59..4d0858cd2a 100644 --- a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/group/entity/JpaGroupMetadata.java +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/group/entity/JpaGroupMetadata.java @@ -40,4 +40,6 @@ public class JpaGroupMetadata extends MapGroupEntityImpl implements Serializable this.entityVersion = entityVersion; } + private String metadataClass = this.getClass().getCanonicalName(); + } diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/hibernate/jsonb/JsonbMetadataBuilderContributor.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/hibernate/jsonb/JsonbMetadataBuilderContributor.java new file mode 100644 index 0000000000..c2b6d4d220 --- /dev/null +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/hibernate/jsonb/JsonbMetadataBuilderContributor.java @@ -0,0 +1,39 @@ +/* + * Copyright 2023 Red Hat, Inc. and/or its affiliates + * and other contributors as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.keycloak.models.map.storage.jpa.hibernate.jsonb; + +import org.hibernate.boot.MetadataBuilder; +import org.hibernate.boot.spi.MetadataBuilderContributor; +import org.hibernate.query.sqm.function.FunctionKind; +import org.hibernate.query.sqm.function.PatternBasedSqmFunctionDescriptor; +import org.hibernate.query.sqm.produce.function.StandardArgumentsValidators; +import org.hibernate.query.sqm.produce.function.internal.PatternRenderer; + +/** + * A {@link MetadataBuilderContributor} to register JSONB types/functions. + */ +public class JsonbMetadataBuilderContributor implements MetadataBuilderContributor { + + @Override + public void contribute(MetadataBuilder metadataBuilder) { + metadataBuilder.applyBasicType(JsonbType.INSTANCE); + metadataBuilder.applySqlFunction("->>", new PatternBasedSqmFunctionDescriptor( + new PatternRenderer("?1->>?2"), StandardArgumentsValidators.exactly(2), null, null, "->>", + FunctionKind.NORMAL, null + )); + } +} diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/hibernate/jsonb/JsonbType.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/hibernate/jsonb/JsonbType.java index 993b2ca09b..7a0db4834f 100644 --- a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/hibernate/jsonb/JsonbType.java +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/hibernate/jsonb/JsonbType.java @@ -227,15 +227,20 @@ public class JsonbType extends AbstractSingleColumnStandardBasicType imp try { ObjectNode tree = MAPPER.readValue(json.toString(), ObjectNode.class); JsonNode ev = tree.get("entityVersion"); + JsonNode mc = tree.get("metadataClass"); if (ev == null || ! ev.isInt()) throw new IllegalArgumentException("unable to read entity version from " + json); Integer entityVersion = ev.asInt(); tree = migrate(tree, entityVersion); + String metadataClass = mc.asText(); + valueType = Class.forName(metadataClass); return MAPPER.treeToValue(tree, valueType); } catch (IOException e) { throw new HibernateException("unable to read", e); + } catch (ClassNotFoundException e) { + throw new RuntimeException(e); } } diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/loginFailure/entity/JpaUserLoginFailureMetadata.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/loginFailure/entity/JpaUserLoginFailureMetadata.java index 0aea5e2521..749241faf8 100644 --- a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/loginFailure/entity/JpaUserLoginFailureMetadata.java +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/loginFailure/entity/JpaUserLoginFailureMetadata.java @@ -45,4 +45,7 @@ public class JpaUserLoginFailureMetadata extends MapUserLoginFailureEntityImpl i public void setEntityVersion(Integer entityVersion) { this.entityVersion = entityVersion; } + + private String metadataClass = this.getClass().getCanonicalName(); + } diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/realm/entity/JpaComponentMetadata.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/realm/entity/JpaComponentMetadata.java index a314ff3961..134ac758aa 100644 --- a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/realm/entity/JpaComponentMetadata.java +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/realm/entity/JpaComponentMetadata.java @@ -45,4 +45,7 @@ public class JpaComponentMetadata extends MapComponentEntityImpl implements Seri public void setEntityVersion(Integer entityVersion) { this.entityVersion = entityVersion; } + + private String metadataClass = this.getClass().getCanonicalName(); + } diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/realm/entity/JpaRealmMetadata.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/realm/entity/JpaRealmMetadata.java index 3ec56f0394..69118da96f 100644 --- a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/realm/entity/JpaRealmMetadata.java +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/realm/entity/JpaRealmMetadata.java @@ -45,4 +45,6 @@ public class JpaRealmMetadata extends MapRealmEntityImpl implements Serializable public void setEntityVersion(Integer entityVersion) { this.entityVersion = entityVersion; } + + private String metadataClass = this.getClass().getCanonicalName(); } diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/role/entity/JpaRoleMetadata.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/role/entity/JpaRoleMetadata.java index 69f06e8f97..f7ec5dea48 100644 --- a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/role/entity/JpaRoleMetadata.java +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/role/entity/JpaRoleMetadata.java @@ -40,4 +40,6 @@ public class JpaRoleMetadata extends MapRoleEntityImpl implements Serializable { this.entityVersion = entityVersion; } + private String metadataClass = this.getClass().getCanonicalName(); + } diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/singleUseObject/entity/JpaSingleUseObjectMetadata.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/singleUseObject/entity/JpaSingleUseObjectMetadata.java index 405f06e585..3773602b05 100644 --- a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/singleUseObject/entity/JpaSingleUseObjectMetadata.java +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/singleUseObject/entity/JpaSingleUseObjectMetadata.java @@ -45,4 +45,7 @@ public class JpaSingleUseObjectMetadata extends MapSingleUseObjectEntityImpl imp public void setEntityVersion(Integer entityVersion) { this.entityVersion = entityVersion; } + + private String metadataClass = this.getClass().getCanonicalName(); + } diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/user/entity/JpaUserConsentMetadata.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/user/entity/JpaUserConsentMetadata.java index f79f72607b..25cb8bcd41 100644 --- a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/user/entity/JpaUserConsentMetadata.java +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/user/entity/JpaUserConsentMetadata.java @@ -45,4 +45,7 @@ public class JpaUserConsentMetadata extends MapUserConsentEntityImpl implements public void setEntityVersion(Integer entityVersion) { this.entityVersion = entityVersion; } + + private String metadataClass = this.getClass().getCanonicalName(); + } diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/user/entity/JpaUserFederatedIdentityMetadata.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/user/entity/JpaUserFederatedIdentityMetadata.java index 9ee907d089..9d6e1431fd 100644 --- a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/user/entity/JpaUserFederatedIdentityMetadata.java +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/user/entity/JpaUserFederatedIdentityMetadata.java @@ -45,4 +45,7 @@ public class JpaUserFederatedIdentityMetadata extends MapUserFederatedIdentityEn public void setEntityVersion(Integer entityVersion) { this.entityVersion = entityVersion; } + + private String metadataClass = this.getClass().getCanonicalName(); + } diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/user/entity/JpaUserMetadata.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/user/entity/JpaUserMetadata.java index 998a622a24..f2df22e475 100644 --- a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/user/entity/JpaUserMetadata.java +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/user/entity/JpaUserMetadata.java @@ -54,4 +54,7 @@ public class JpaUserMetadata extends MapUserEntityImpl implements Serializable { public String getUsernameWithCase() { return this.usernameWithCase; } + + private String metadataClass = this.getClass().getCanonicalName(); + } diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/userSession/entity/JpaClientSessionMetadata.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/userSession/entity/JpaClientSessionMetadata.java index 4bcc03703f..2a3e3e2406 100644 --- a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/userSession/entity/JpaClientSessionMetadata.java +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/userSession/entity/JpaClientSessionMetadata.java @@ -40,4 +40,6 @@ public class JpaClientSessionMetadata extends MapAuthenticatedClientSessionEntit this.entityVersion = entityVersion; } + private String metadataClass = this.getClass().getCanonicalName(); + } diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/userSession/entity/JpaUserSessionMetadata.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/userSession/entity/JpaUserSessionMetadata.java index ab71041e95..c0eba688bb 100644 --- a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/userSession/entity/JpaUserSessionMetadata.java +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/userSession/entity/JpaUserSessionMetadata.java @@ -40,4 +40,6 @@ public class JpaUserSessionMetadata extends MapUserSessionEntityImpl implements this.entityVersion = entityVersion; } + private String metadataClass = this.getClass().getCanonicalName(); + } diff --git a/model/map-jpa/src/main/resources/default-map-jpa-persistence.xml b/model/map-jpa/src/main/resources/default-map-jpa-persistence.xml index 976d247b8e..14d9bdd5cf 100644 --- a/model/map-jpa/src/main/resources/default-map-jpa-persistence.xml +++ b/model/map-jpa/src/main/resources/default-map-jpa-persistence.xml @@ -16,7 +16,10 @@ ~ limitations under the License. --> - + org.keycloak.models.map.storage.jpa.authSession.entity.JpaRootAuthenticationSessionEntity