Use proper @Type annotation for JSON type

Fixes: #16335
---
Quarkus3 branch sync no. 11 (24.3.2023)
Resolved conflicts:
keycloak/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/JpaMapStorageProviderFactory.java - Modified
---
Quarkus3 branch sync no. 7 (27.2.2023)
Resolved conflicts:
keycloak/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/client/entity/JpaClientEntity.java - Modified
keycloak/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/clientScope/entity/JpaClientScopeEntity.java - Modified
This commit is contained in:
Hynek Mlnarik 2023-01-16 15:35:08 +01:00 committed by Václav Muzikář
parent 4ff2de7f46
commit 386c58c78b
46 changed files with 54 additions and 136 deletions

View file

@ -46,15 +46,11 @@ import jakarta.transaction.RollbackException;
import jakarta.transaction.SystemException;
import jakarta.transaction.Transaction;
import org.hibernate.boot.MetadataBuilder;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.internal.SessionImpl;
import org.hibernate.jpa.boot.internal.ParsedPersistenceXmlDescriptor;
import org.hibernate.jpa.boot.internal.PersistenceXmlParser;
import org.hibernate.jpa.boot.spi.Bootstrap;
import org.hibernate.service.ServiceRegistry;
import org.jboss.logging.Logger;
import org.keycloak.Config;
import org.keycloak.authorization.model.PermissionTicket;

View file

@ -30,9 +30,7 @@ import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import jakarta.persistence.Version;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;
import org.hibernate.usertype.UserTypeLegacyBridge;
import org.keycloak.models.map.authSession.MapAuthenticationSessionEntity;
import org.keycloak.models.map.common.DeepCloner;
import org.keycloak.models.map.common.UpdatableEntity;
@ -41,6 +39,7 @@ import static org.keycloak.models.map.storage.jpa.authSession.entity.JpaAuthenti
import org.keycloak.models.map.storage.jpa.JpaChildEntity;
import org.keycloak.models.map.storage.jpa.JpaRootVersionedEntity;
import org.keycloak.models.map.storage.jpa.hibernate.jsonb.JsonbType;
import org.keycloak.sessions.CommonClientSessionModel;
/**
@ -65,7 +64,7 @@ public class JpaAuthenticationSessionEntity extends UpdatableEntity.Impl impleme
@Basic(fetch = FetchType.LAZY)
private Integer entityVersion;
@Type(value = UserTypeLegacyBridge.class, parameters = @Parameter(name = UserTypeLegacyBridge.TYPE_NAME_PARAM_KEY, value = "jsonb"))
@Type(JsonbType.class)
@Column(columnDefinition = "jsonb")
private final JpaAuthenticationSessionMetadata metadata;

View file

@ -40,6 +40,4 @@ public class JpaAuthenticationSessionMetadata extends MapAuthenticationSessionEn
this.entityVersion = entityVersion;
}
private String metadataClass = this.getClass().getCanonicalName();
}

View file

@ -31,9 +31,7 @@ import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import jakarta.persistence.Version;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;
import org.hibernate.usertype.UserTypeLegacyBridge;
import org.keycloak.models.map.authSession.MapAuthenticationSessionEntity;
import org.keycloak.models.map.authSession.MapRootAuthenticationSessionEntity.AbstractRootAuthenticationSessionEntity;
import org.keycloak.models.map.common.DeepCloner;
@ -41,6 +39,7 @@ import org.keycloak.models.map.common.UuidValidator;
import org.keycloak.models.map.storage.jpa.Constants;
import org.keycloak.models.map.storage.jpa.JpaRootVersionedEntity;
import org.keycloak.models.map.storage.jpa.hibernate.jsonb.JsonbType;
import static org.keycloak.models.map.storage.jpa.JpaMapStorageProviderFactory.CLONER;
import static org.keycloak.models.map.storage.jpa.authSession.entity.JpaRootAuthenticationSessionEntity.TABLE_NAME;
@ -66,7 +65,7 @@ public class JpaRootAuthenticationSessionEntity extends AbstractRootAuthenticati
@Column
private int version;
@Type(value = UserTypeLegacyBridge.class, parameters = @Parameter(name = UserTypeLegacyBridge.TYPE_NAME_PARAM_KEY, value = "jsonb"))
@Type(JsonbType.class)
@Column(columnDefinition = "jsonb")
private final JpaRootAuthenticationSessionMetadata metadata;

View file

@ -40,6 +40,4 @@ public class JpaRootAuthenticationSessionMetadata extends MapRootAuthenticationS
this.entityVersion = entityVersion;
}
private String metadataClass = this.getClass().getCanonicalName();
}

View file

@ -26,14 +26,13 @@ import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import jakarta.persistence.Version;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;
import org.hibernate.usertype.UserTypeLegacyBridge;
import org.keycloak.models.map.authorization.entity.MapPermissionTicketEntity.AbstractMapPermissionTicketEntity;
import org.keycloak.models.map.common.DeepCloner;
import org.keycloak.models.map.common.UuidValidator;
import org.keycloak.models.map.storage.jpa.Constants;
import org.keycloak.models.map.storage.jpa.JpaRootVersionedEntity;
import org.keycloak.models.map.storage.jpa.hibernate.jsonb.JsonbType;
/**
@ -54,7 +53,7 @@ public class JpaPermissionEntity extends AbstractMapPermissionTicketEntity imple
@Column
private int version;
@Type(value = UserTypeLegacyBridge.class, parameters = @Parameter(name = UserTypeLegacyBridge.TYPE_NAME_PARAM_KEY, value = "jsonb"))
@Type(JsonbType.class)
@Column(columnDefinition = "jsonb")
private final JpaPermissionMetadata metadata;

View file

@ -40,6 +40,4 @@ public class JpaPermissionMetadata extends MapPermissionTicketEntityImpl impleme
this.entityVersion = entityVersion;
}
private String metadataClass = this.getClass().getCanonicalName();
}

View file

@ -36,15 +36,14 @@ import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import jakarta.persistence.Version;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;
import org.hibernate.usertype.UserTypeLegacyBridge;
import org.keycloak.models.map.authorization.entity.MapPolicyEntity.AbstractMapPolicyEntity;
import org.keycloak.models.map.common.DeepCloner;
import org.keycloak.models.map.common.StringKeyConverter;
import org.keycloak.models.map.common.UuidValidator;
import org.keycloak.models.map.storage.jpa.Constants;
import org.keycloak.models.map.storage.jpa.JpaRootVersionedEntity;
import org.keycloak.models.map.storage.jpa.hibernate.jsonb.JsonbType;
import org.keycloak.representations.idm.authorization.DecisionStrategy;
import org.keycloak.representations.idm.authorization.Logic;
@ -66,7 +65,7 @@ public class JpaPolicyEntity extends AbstractMapPolicyEntity implements JpaRootV
@Column
private int version;
@Type(value = UserTypeLegacyBridge.class, parameters = @Parameter(name = UserTypeLegacyBridge.TYPE_NAME_PARAM_KEY, value = "jsonb"))
@Type(JsonbType.class)
@Column(columnDefinition = "jsonb")
private final JpaPolicyMetadata metadata;

View file

@ -40,6 +40,4 @@ public class JpaPolicyMetadata extends MapPolicyEntityImpl implements Serializab
this.entityVersion = entityVersion;
}
private String metadataClass = this.getClass().getCanonicalName();
}

View file

@ -38,15 +38,14 @@ import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import jakarta.persistence.Version;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;
import org.hibernate.usertype.UserTypeLegacyBridge;
import org.keycloak.models.map.authorization.entity.MapResourceEntity.AbstractMapResourceEntity;
import org.keycloak.models.map.common.DeepCloner;
import org.keycloak.models.map.common.StringKeyConverter;
import org.keycloak.models.map.common.UuidValidator;
import org.keycloak.models.map.storage.jpa.Constants;
import org.keycloak.models.map.storage.jpa.JpaRootVersionedEntity;
import org.keycloak.models.map.storage.jpa.hibernate.jsonb.JsonbType;
/**
@ -67,7 +66,7 @@ public class JpaResourceEntity extends AbstractMapResourceEntity implements JpaR
@Column
private int version;
@Type(value = UserTypeLegacyBridge.class, parameters = @Parameter(name = UserTypeLegacyBridge.TYPE_NAME_PARAM_KEY, value = "jsonb"))
@Type(JsonbType.class)
@Column(columnDefinition = "jsonb")
private final JpaResourceMetadata metadata;

View file

@ -40,6 +40,4 @@ public class JpaResourceMetadata extends MapResourceEntityImpl implements Serial
this.entityVersion = entityVersion;
}
private String metadataClass = this.getClass().getCanonicalName();
}

View file

@ -26,14 +26,13 @@ import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import jakarta.persistence.Version;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;
import org.hibernate.usertype.UserTypeLegacyBridge;
import org.keycloak.models.map.authorization.entity.MapResourceServerEntity.AbstractMapResourceServerEntity;
import org.keycloak.models.map.common.DeepCloner;
import org.keycloak.models.map.common.UuidValidator;
import org.keycloak.models.map.storage.jpa.Constants;
import org.keycloak.models.map.storage.jpa.JpaRootVersionedEntity;
import org.keycloak.models.map.storage.jpa.hibernate.jsonb.JsonbType;
import org.keycloak.representations.idm.authorization.DecisionStrategy;
import org.keycloak.representations.idm.authorization.PolicyEnforcementMode;
@ -56,7 +55,7 @@ public class JpaResourceServerEntity extends AbstractMapResourceServerEntity imp
@Column
private int version;
@Type(value = UserTypeLegacyBridge.class, parameters = @Parameter(name = UserTypeLegacyBridge.TYPE_NAME_PARAM_KEY, value = "jsonb"))
@Type(JsonbType.class)
@Column(columnDefinition = "jsonb")
private final JpaResourceServerMetadata metadata;

View file

@ -40,6 +40,4 @@ public class JpaResourceServerMetadata extends MapResourceServerEntityImpl imple
this.entityVersion = entityVersion;
}
private String metadataClass = this.getClass().getCanonicalName();
}

View file

@ -26,14 +26,13 @@ import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import jakarta.persistence.Version;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;
import org.hibernate.usertype.UserTypeLegacyBridge;
import org.keycloak.models.map.authorization.entity.MapScopeEntity.AbstractMapScopeEntity;
import org.keycloak.models.map.common.DeepCloner;
import org.keycloak.models.map.common.UuidValidator;
import org.keycloak.models.map.storage.jpa.Constants;
import org.keycloak.models.map.storage.jpa.JpaRootVersionedEntity;
import org.keycloak.models.map.storage.jpa.hibernate.jsonb.JsonbType;
/**
@ -54,7 +53,7 @@ public class JpaScopeEntity extends AbstractMapScopeEntity implements JpaRootVer
@Column
private int version;
@Type(value = UserTypeLegacyBridge.class, parameters = @Parameter(name = UserTypeLegacyBridge.TYPE_NAME_PARAM_KEY, value = "jsonb"))
@Type(JsonbType.class)
@Column(columnDefinition = "jsonb")
private final JpaScopeMetadata metadata;

View file

@ -40,6 +40,4 @@ public class JpaScopeMetadata extends MapScopeEntityImpl implements Serializable
this.entityVersion = entityVersion;
}
private String metadataClass = this.getClass().getCanonicalName();
}

View file

@ -36,9 +36,7 @@ import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import jakarta.persistence.Version;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;
import org.hibernate.usertype.UserTypeLegacyBridge;
import org.keycloak.models.map.client.MapClientEntity.AbstractClientEntity;
import org.keycloak.models.map.client.MapProtocolMapperEntity;
import org.keycloak.models.map.common.DeepCloner;
@ -72,7 +70,7 @@ public class JpaClientEntity extends AbstractClientEntity implements JpaRootVers
@Column
private int version;
@Type(value = UserTypeLegacyBridge.class, parameters = @Parameter(name = UserTypeLegacyBridge.TYPE_NAME_PARAM_KEY, value = "jsonb"))
@Type(JsonbType.class)
@Column(columnDefinition = "jsonb")
private final JpaClientMetadata metadata;

View file

@ -40,6 +40,4 @@ public class JpaClientMetadata extends MapClientEntityImpl implements Serializab
this.entityVersion = entityVersion;
}
private String metadataClass = this.getClass().getCanonicalName();
}

View file

@ -36,9 +36,7 @@ import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import jakarta.persistence.Version;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;
import org.hibernate.usertype.UserTypeLegacyBridge;
import org.keycloak.models.map.client.MapProtocolMapperEntity;
import org.keycloak.models.map.clientscope.MapClientScopeEntity.AbstractClientScopeEntity;
import org.keycloak.models.map.common.DeepCloner;
@ -67,7 +65,7 @@ public class JpaClientScopeEntity extends AbstractClientScopeEntity implements J
@Column
private int version;
@Type(value = UserTypeLegacyBridge.class, parameters = @Parameter(name = UserTypeLegacyBridge.TYPE_NAME_PARAM_KEY, value = "jsonb"))
@Type(JsonbType.class)
@Column(columnDefinition = "jsonb")
private final JpaClientScopeMetadata metadata;

View file

@ -40,6 +40,4 @@ public class JpaClientScopeMetadata extends MapClientScopeEntityImpl implements
this.entityVersion = entityVersion;
}
private String metadataClass = this.getClass().getCanonicalName();
}

View file

@ -27,15 +27,14 @@ import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.persistence.Version;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;
import org.hibernate.usertype.UserTypeLegacyBridge;
import org.keycloak.events.admin.OperationType;
import org.keycloak.models.map.common.DeepCloner;
import org.keycloak.models.map.common.UuidValidator;
import org.keycloak.models.map.events.MapAdminEventEntity;
import org.keycloak.models.map.storage.jpa.JpaRootVersionedEntity;
import org.keycloak.models.map.storage.jpa.hibernate.jsonb.JsonbType;
import static org.keycloak.models.map.storage.jpa.Constants.CURRENT_SCHEMA_VERSION_ADMIN_EVENT;
/**
@ -57,7 +56,7 @@ public class JpaAdminEventEntity extends MapAdminEventEntity.AbstractAdminEventE
@Column
private int version;
@Type(value = UserTypeLegacyBridge.class, parameters = @Parameter(name = UserTypeLegacyBridge.TYPE_NAME_PARAM_KEY, value = "jsonb"))
@Type(JsonbType.class)
@Column(columnDefinition = "jsonb")
private final JpaAdminEventMetadata metadata;

View file

@ -46,6 +46,4 @@ public class JpaAdminEventMetadata extends MapAdminEventEntityImpl implements Se
this.entityVersion = entityVersion;
}
private String metadataClass = this.getClass().getCanonicalName();
}

View file

@ -33,15 +33,14 @@ import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import jakarta.persistence.Version;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;
import org.hibernate.usertype.UserTypeLegacyBridge;
import org.keycloak.events.EventType;
import org.keycloak.models.map.common.DeepCloner;
import org.keycloak.models.map.common.UuidValidator;
import org.keycloak.models.map.events.MapAuthEventEntity;
import org.keycloak.models.map.storage.jpa.JpaRootVersionedEntity;
import org.keycloak.models.map.storage.jpa.hibernate.jsonb.JsonbType;
import static org.keycloak.models.map.storage.jpa.Constants.CURRENT_SCHEMA_VERSION_AUTH_EVENT;
/**
@ -63,7 +62,7 @@ public class JpaAuthEventEntity extends MapAuthEventEntity.AbstractAuthEventEnti
@Column
private int version;
@Type(value = UserTypeLegacyBridge.class, parameters = @Parameter(name = UserTypeLegacyBridge.TYPE_NAME_PARAM_KEY, value = "jsonb"))
@Type(JsonbType.class)
@Column(columnDefinition = "jsonb")
private final JpaAuthEventMetadata metadata;

View file

@ -46,6 +46,4 @@ public class JpaAuthEventMetadata extends MapAuthEventEntityImpl implements Seri
this.entityVersion = entityVersion;
}
private String metadataClass = this.getClass().getCanonicalName();
}

View file

@ -35,14 +35,13 @@ import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import jakarta.persistence.Version;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;
import org.hibernate.usertype.UserTypeLegacyBridge;
import org.keycloak.models.map.common.DeepCloner;
import org.keycloak.models.map.common.UuidValidator;
import org.keycloak.models.map.group.MapGroupEntity.AbstractGroupEntity;
import static org.keycloak.models.map.storage.jpa.Constants.CURRENT_SCHEMA_VERSION_GROUP;
import org.keycloak.models.map.storage.jpa.JpaRootVersionedEntity;
import org.keycloak.models.map.storage.jpa.hibernate.jsonb.JsonbType;
/**
* There are some fields marked by {@code @Column(insertable = false, updatable = false)}.
@ -62,7 +61,7 @@ public class JpaGroupEntity extends AbstractGroupEntity implements JpaRootVersio
@Column
private int version;
@Type(value = UserTypeLegacyBridge.class, parameters = @Parameter(name = UserTypeLegacyBridge.TYPE_NAME_PARAM_KEY, value = "jsonb"))
@Type(JsonbType.class)
@Column(columnDefinition = "jsonb")
private final JpaGroupMetadata metadata;

View file

@ -40,6 +40,4 @@ public class JpaGroupMetadata extends MapGroupEntityImpl implements Serializable
this.entityVersion = entityVersion;
}
private String metadataClass = this.getClass().getCanonicalName();
}

View file

@ -40,7 +40,6 @@ import java.util.Map;
import java.util.Objects;
import java.util.Properties;
import org.hibernate.HibernateException;
import org.hibernate.type.AbstractSingleColumnStandardBasicType;
import org.hibernate.type.descriptor.ValueBinder;
import org.hibernate.type.descriptor.ValueExtractor;
import org.hibernate.type.descriptor.WrapperOptions;
@ -81,8 +80,10 @@ import org.keycloak.models.map.realm.entity.MapWebAuthnPolicyEntityImpl;
import org.keycloak.models.map.user.MapUserCredentialEntity;
import org.keycloak.models.map.user.MapUserCredentialEntityImpl;
import org.keycloak.util.EnumWithStableIndex;
import java.util.function.BiConsumer;
import org.hibernate.usertype.BaseUserTypeSupport;
public class JsonbType extends AbstractSingleColumnStandardBasicType<Object> implements DynamicParameterizedType {
public class JsonbType extends BaseUserTypeSupport<Object> implements DynamicParameterizedType {
public static final JsonbType INSTANCE = new JsonbType();
public static final ObjectMapper MAPPER = new ObjectMapper()
@ -112,7 +113,6 @@ public class JsonbType extends AbstractSingleColumnStandardBasicType<Object> imp
.addMixIn(EntityWithAttributes.class, IgnoredMetadataFieldsMixIn.class)
.addMixIn(EnumWithStableIndex.class, EnumsMixIn.class)
;
abstract class IgnoredMetadataFieldsMixIn {
@JsonIgnore public abstract String getId();
@JsonIgnore public abstract Map<String, List<String>> getAttributes();
@ -128,18 +128,17 @@ public class JsonbType extends AbstractSingleColumnStandardBasicType<Object> imp
@JsonValue public abstract int getStableIndex();
}
public JsonbType() {
super(JsonbSqlTypeDescriptor.INSTANCE, new JsonbJavaTypeDescriptor());
}
private Class valueType;
@Override
@SuppressWarnings("unchecked")
protected void resolve(BiConsumer resolutionConsumer) {
resolutionConsumer.accept(new JsonbJavaTypeDescriptor(), JsonbSqlTypeDescriptor.INSTANCE);
}
@Override
public void setParameterValues(Properties parameters) {
((JsonbJavaTypeDescriptor) getJavaTypeDescriptor()).setParameterValues(parameters);
}
@Override
public String getName() {
return "jsonb";
this.valueType = ((ParameterType) parameters.get(PARAMETER_TYPE)).getReturnedClass();
}
private static class JsonbSqlTypeDescriptor implements JdbcType {
@ -199,14 +198,7 @@ public class JsonbType extends AbstractSingleColumnStandardBasicType<Object> imp
}
}
private static class JsonbJavaTypeDescriptor extends AbstractJavaType<Object> implements DynamicParameterizedType {
private Class valueType;
@Override
public void setParameterValues(Properties parameters) {
valueType = ((ParameterType) parameters.get(PARAMETER_TYPE)).getReturnedClass();
}
private class JsonbJavaTypeDescriptor extends AbstractJavaType<Object> {
public JsonbJavaTypeDescriptor() {
super(Object.class, new MutableMutabilityPlan<Object>() {
@ -227,20 +219,15 @@ public class JsonbType extends AbstractSingleColumnStandardBasicType<Object> 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);
}
}

View file

@ -36,6 +36,7 @@ import org.keycloak.models.map.common.UuidValidator;
import org.keycloak.models.map.loginFailure.MapUserLoginFailureEntity;
import org.keycloak.models.map.storage.jpa.JpaRootVersionedEntity;
import org.keycloak.models.map.storage.jpa.hibernate.jsonb.JsonbType;
import static org.keycloak.models.map.storage.jpa.Constants.CURRENT_SCHEMA_VERSION_USER_LOGIN_FAILURE;
/**
@ -62,7 +63,7 @@ public class JpaUserLoginFailureEntity extends MapUserLoginFailureEntity.Abstrac
@Column
private int version;
@Type(value = UserTypeLegacyBridge.class, parameters = @Parameter(name = UserTypeLegacyBridge.TYPE_NAME_PARAM_KEY, value = "jsonb"))
@Type(JsonbType.class)
@Column(columnDefinition = "jsonb")
private final JpaUserLoginFailureMetadata metadata;

View file

@ -46,6 +46,4 @@ public class JpaUserLoginFailureMetadata extends MapUserLoginFailureEntityImpl i
this.entityVersion = entityVersion;
}
private String metadataClass = this.getClass().getCanonicalName();
}

View file

@ -31,9 +31,7 @@ import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import jakarta.persistence.Version;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;
import org.hibernate.usertype.UserTypeLegacyBridge;
import org.keycloak.models.map.common.DeepCloner;
import org.keycloak.models.map.common.UpdatableEntity;
import org.keycloak.models.map.common.UuidValidator;
@ -41,6 +39,7 @@ import org.keycloak.models.map.realm.entity.MapComponentEntity;
import org.keycloak.models.map.storage.jpa.Constants;
import org.keycloak.models.map.storage.jpa.JpaChildEntity;
import org.keycloak.models.map.storage.jpa.JpaRootVersionedEntity;
import org.keycloak.models.map.storage.jpa.hibernate.jsonb.JsonbType;
/**
@ -77,7 +76,7 @@ public class JpaComponentEntity extends UpdatableEntity.Impl implements MapCompo
@Basic(fetch = FetchType.LAZY)
private String providerType;
@Type(value = UserTypeLegacyBridge.class, parameters = @Parameter(name = UserTypeLegacyBridge.TYPE_NAME_PARAM_KEY, value = "jsonb"))
@Type(JsonbType.class)
@Column(columnDefinition = "jsonb")
private final JpaComponentMetadata metadata;

View file

@ -46,6 +46,4 @@ public class JpaComponentMetadata extends MapComponentEntityImpl implements Seri
this.entityVersion = entityVersion;
}
private String metadataClass = this.getClass().getCanonicalName();
}

View file

@ -38,9 +38,7 @@ import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import jakarta.persistence.Version;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;
import org.hibernate.usertype.UserTypeLegacyBridge;
import org.keycloak.models.map.common.DeepCloner;
import org.keycloak.models.map.common.UuidValidator;
import org.keycloak.models.map.realm.MapRealmEntity;
@ -58,6 +56,7 @@ import org.keycloak.models.map.realm.entity.MapWebAuthnPolicyEntity;
import org.keycloak.models.map.storage.jpa.Constants;
import org.keycloak.models.map.storage.jpa.JpaRootVersionedEntity;
import org.keycloak.models.map.storage.jpa.hibernate.jsonb.JsonbType;
import static org.keycloak.models.map.storage.jpa.JpaMapStorageProviderFactory.CLONER;
/**
@ -85,7 +84,7 @@ public class JpaRealmEntity extends MapRealmEntity.AbstractRealmEntity implement
@Column
private int version;
@Type(value = UserTypeLegacyBridge.class, parameters = @Parameter(name = UserTypeLegacyBridge.TYPE_NAME_PARAM_KEY, value = "jsonb"))
@Type(JsonbType.class)
@Column(columnDefinition = "jsonb")
private final JpaRealmMetadata metadata;

View file

@ -46,5 +46,4 @@ public class JpaRealmMetadata extends MapRealmEntityImpl implements Serializable
this.entityVersion = entityVersion;
}
private String metadataClass = this.getClass().getCanonicalName();
}

View file

@ -35,14 +35,13 @@ import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import jakarta.persistence.Version;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;
import org.hibernate.usertype.UserTypeLegacyBridge;
import org.keycloak.models.map.common.DeepCloner;
import org.keycloak.models.map.common.UuidValidator;
import org.keycloak.models.map.role.MapRoleEntity.AbstractRoleEntity;
import static org.keycloak.models.map.storage.jpa.Constants.CURRENT_SCHEMA_VERSION_ROLE;
import org.keycloak.models.map.storage.jpa.JpaRootVersionedEntity;
import org.keycloak.models.map.storage.jpa.hibernate.jsonb.JsonbType;
/**
* There are some fields marked by {@code @Column(insertable = false, updatable = false)}.
@ -62,7 +61,7 @@ public class JpaRoleEntity extends AbstractRoleEntity implements JpaRootVersione
@Column
private int version;
@Type(value = UserTypeLegacyBridge.class, parameters = @Parameter(name = UserTypeLegacyBridge.TYPE_NAME_PARAM_KEY, value = "jsonb"))
@Type(JsonbType.class)
@Column(columnDefinition = "jsonb")
private final JpaRoleMetadata metadata;

View file

@ -40,6 +40,4 @@ public class JpaRoleMetadata extends MapRoleEntityImpl implements Serializable {
this.entityVersion = entityVersion;
}
private String metadataClass = this.getClass().getCanonicalName();
}

View file

@ -33,14 +33,13 @@ import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import jakarta.persistence.Version;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;
import org.hibernate.usertype.UserTypeLegacyBridge;
import org.keycloak.models.map.common.DeepCloner;
import org.keycloak.models.map.common.UuidValidator;
import org.keycloak.models.map.singleUseObject.MapSingleUseObjectEntity;
import org.keycloak.models.map.storage.jpa.JpaRootVersionedEntity;
import org.keycloak.models.map.storage.jpa.hibernate.jsonb.JsonbType;
import static org.keycloak.models.map.storage.jpa.Constants.CURRENT_SCHEMA_VERSION_SINGLE_USE_OBJECT;
/**
@ -62,7 +61,7 @@ public class JpaSingleUseObjectEntity extends MapSingleUseObjectEntity.AbstractS
@Column
private int version;
@Type(value = UserTypeLegacyBridge.class, parameters = @Parameter(name = UserTypeLegacyBridge.TYPE_NAME_PARAM_KEY, value = "jsonb"))
@Type(JsonbType.class)
@Column(columnDefinition = "jsonb")
private final JpaSingleUseObjectMetadata metadata;

View file

@ -46,6 +46,4 @@ public class JpaSingleUseObjectMetadata extends MapSingleUseObjectEntityImpl imp
this.entityVersion = entityVersion;
}
private String metadataClass = this.getClass().getCanonicalName();
}

View file

@ -31,14 +31,13 @@ import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;
import org.hibernate.usertype.UserTypeLegacyBridge;
import org.keycloak.models.map.common.DeepCloner;
import org.keycloak.models.map.common.UpdatableEntity;
import org.keycloak.models.map.storage.jpa.Constants;
import org.keycloak.models.map.storage.jpa.JpaChildEntity;
import org.keycloak.models.map.storage.jpa.JpaRootEntity;
import org.keycloak.models.map.storage.jpa.hibernate.jsonb.JsonbType;
import org.keycloak.models.map.user.MapUserConsentEntity;
/**
@ -67,7 +66,7 @@ public class JpaUserConsentEntity extends UpdatableEntity.Impl implements MapUse
@Basic(fetch = FetchType.LAZY)
private Integer entityVersion;
@Type(value = UserTypeLegacyBridge.class, parameters = @Parameter(name = UserTypeLegacyBridge.TYPE_NAME_PARAM_KEY, value = "jsonb"))
@Type(JsonbType.class)
@Column(columnDefinition = "jsonb")
private final JpaUserConsentMetadata metadata;

View file

@ -46,6 +46,4 @@ public class JpaUserConsentMetadata extends MapUserConsentEntityImpl implements
this.entityVersion = entityVersion;
}
private String metadataClass = this.getClass().getCanonicalName();
}

View file

@ -40,13 +40,12 @@ import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import jakarta.persistence.Version;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;
import org.hibernate.usertype.UserTypeLegacyBridge;
import org.keycloak.models.map.common.DeepCloner;
import org.keycloak.models.map.common.UuidValidator;
import org.keycloak.models.map.storage.jpa.Constants;
import org.keycloak.models.map.storage.jpa.JpaRootVersionedEntity;
import org.keycloak.models.map.storage.jpa.hibernate.jsonb.JsonbType;
import org.keycloak.models.map.user.MapUserConsentEntity;
import org.keycloak.models.map.user.MapUserCredentialEntity;
import org.keycloak.models.map.user.MapUserEntity;
@ -81,7 +80,7 @@ public class JpaUserEntity extends MapUserEntity.AbstractUserEntity implements J
@Column
private int version;
@Type(value = UserTypeLegacyBridge.class, parameters = @Parameter(name = UserTypeLegacyBridge.TYPE_NAME_PARAM_KEY, value = "jsonb"))
@Type(JsonbType.class)
@Column(columnDefinition = "jsonb")
private final JpaUserMetadata metadata;

View file

@ -29,14 +29,13 @@ import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;
import org.hibernate.usertype.UserTypeLegacyBridge;
import org.keycloak.models.map.common.DeepCloner;
import org.keycloak.models.map.common.UpdatableEntity;
import org.keycloak.models.map.storage.jpa.Constants;
import org.keycloak.models.map.storage.jpa.JpaChildEntity;
import org.keycloak.models.map.storage.jpa.JpaRootEntity;
import org.keycloak.models.map.storage.jpa.hibernate.jsonb.JsonbType;
import org.keycloak.models.map.user.MapUserFederatedIdentityEntity;
/**
@ -66,7 +65,7 @@ public class JpaUserFederatedIdentityEntity extends UpdatableEntity.Impl impleme
@Basic(fetch = FetchType.LAZY)
private String userId;
@Type(value = UserTypeLegacyBridge.class, parameters = @Parameter(name = UserTypeLegacyBridge.TYPE_NAME_PARAM_KEY, value = "jsonb"))
@Type(JsonbType.class)
@Column(columnDefinition = "jsonb")
private final JpaUserFederatedIdentityMetadata metadata;

View file

@ -46,6 +46,4 @@ public class JpaUserFederatedIdentityMetadata extends MapUserFederatedIdentityEn
this.entityVersion = entityVersion;
}
private String metadataClass = this.getClass().getCanonicalName();
}

View file

@ -55,6 +55,4 @@ public class JpaUserMetadata extends MapUserEntityImpl implements Serializable {
return this.usernameWithCase;
}
private String metadataClass = this.getClass().getCanonicalName();
}

View file

@ -33,14 +33,13 @@ import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import jakarta.persistence.Version;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;
import org.hibernate.usertype.UserTypeLegacyBridge;
import org.keycloak.models.map.common.DeepCloner;
import org.keycloak.models.map.common.UuidValidator;
import org.keycloak.models.map.storage.jpa.Constants;
import org.keycloak.models.map.storage.jpa.JpaChildEntity;
import org.keycloak.models.map.storage.jpa.JpaRootVersionedEntity;
import org.keycloak.models.map.storage.jpa.hibernate.jsonb.JsonbType;
import org.keycloak.models.map.userSession.MapAuthenticatedClientSessionEntity.AbstractAuthenticatedClientSessionEntity;
/**
@ -59,7 +58,7 @@ public class JpaClientSessionEntity extends AbstractAuthenticatedClientSessionEn
@Column
private int version;
@Type(value = UserTypeLegacyBridge.class, parameters = @Parameter(name = UserTypeLegacyBridge.TYPE_NAME_PARAM_KEY, value = "jsonb"))
@Type(JsonbType.class)
@Column(columnDefinition = "jsonb")
private final JpaClientSessionMetadata metadata;

View file

@ -40,6 +40,4 @@ public class JpaClientSessionMetadata extends MapAuthenticatedClientSessionEntit
this.entityVersion = entityVersion;
}
private String metadataClass = this.getClass().getCanonicalName();
}

View file

@ -33,14 +33,13 @@ import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import jakarta.persistence.Version;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;
import org.hibernate.usertype.UserTypeLegacyBridge;
import org.keycloak.models.UserSessionModel;
import org.keycloak.models.map.common.DeepCloner;
import org.keycloak.models.map.common.UuidValidator;
import org.keycloak.models.map.storage.jpa.Constants;
import org.keycloak.models.map.storage.jpa.JpaRootVersionedEntity;
import org.keycloak.models.map.storage.jpa.hibernate.jsonb.JsonbType;
import org.keycloak.models.map.userSession.MapAuthenticatedClientSessionEntity;
import org.keycloak.models.map.userSession.MapUserSessionEntity.AbstractUserSessionEntity;
@ -64,7 +63,7 @@ public class JpaUserSessionEntity extends AbstractUserSessionEntity implements J
@Column
private int version;
@Type(value = UserTypeLegacyBridge.class, parameters = @Parameter(name = UserTypeLegacyBridge.TYPE_NAME_PARAM_KEY, value = "jsonb"))
@Type(JsonbType.class)
@Column(columnDefinition = "jsonb")
private final JpaUserSessionMetadata metadata;

View file

@ -40,6 +40,4 @@ public class JpaUserSessionMetadata extends MapUserSessionEntityImpl implements
this.entityVersion = entityVersion;
}
private String metadataClass = this.getClass().getCanonicalName();
}