From 080cc8c2737045e47ec722280553ab878355b1ad Mon Sep 17 00:00:00 2001 From: Alex Morel Date: Fri, 21 Jun 2024 14:11:10 +0200 Subject: [PATCH] Revert "Type "type" column in Hibernate" This reverts commit 0bf5aa1a76aeece12b71b14bedc672850671a794. --- src/main/java/sh/libre/scim/jpa/ScimResource.java | 7 +++---- src/main/java/sh/libre/scim/jpa/ScimResourceDao.java | 4 ++-- src/main/java/sh/libre/scim/jpa/ScimResourceId.java | 11 +++++------ 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/main/java/sh/libre/scim/jpa/ScimResource.java b/src/main/java/sh/libre/scim/jpa/ScimResource.java index cacc92e81d..5536a6dd96 100644 --- a/src/main/java/sh/libre/scim/jpa/ScimResource.java +++ b/src/main/java/sh/libre/scim/jpa/ScimResource.java @@ -9,7 +9,6 @@ import jakarta.persistence.NamedQuery; import jakarta.persistence.Table; import sh.libre.scim.core.EntityOnRemoteScimId; import sh.libre.scim.core.KeycloakId; -import sh.libre.scim.core.ScimResourceType; @Entity @IdClass(ScimResourceId.class) @@ -34,7 +33,7 @@ public class ScimResource { @Id @Column(name = "TYPE", nullable = false) - private ScimResourceType type; + private String type; @Id @Column(name = "EXTERNAL_ID", nullable = false) @@ -72,11 +71,11 @@ public class ScimResource { this.externalId = externalId; } - public ScimResourceType getType() { + public String getType() { return type; } - public void setType(ScimResourceType type) { + public void setType(String type) { this.type = type; } diff --git a/src/main/java/sh/libre/scim/jpa/ScimResourceDao.java b/src/main/java/sh/libre/scim/jpa/ScimResourceDao.java index 02a473cb67..7d96b2819d 100644 --- a/src/main/java/sh/libre/scim/jpa/ScimResourceDao.java +++ b/src/main/java/sh/libre/scim/jpa/ScimResourceDao.java @@ -45,7 +45,7 @@ public class ScimResourceDao { public void create(KeycloakId id, EntityOnRemoteScimId externalId, ScimResourceType type) { ScimResource entity = new ScimResource(); - entity.setType(type); + entity.setType(type.name()); entity.setExternalId(externalId.asString()); entity.setComponentId(componentId); entity.setRealmId(realmId); @@ -56,7 +56,7 @@ public class ScimResourceDao { private TypedQuery getScimResourceTypedQuery(String queryName, String id, ScimResourceType type) { return getEntityManager() .createNamedQuery(queryName, ScimResource.class) - .setParameter("type", type) + .setParameter("type", type.name()) .setParameter("realmId", getRealmId()) .setParameter("componentId", getComponentId()) .setParameter("id", id); diff --git a/src/main/java/sh/libre/scim/jpa/ScimResourceId.java b/src/main/java/sh/libre/scim/jpa/ScimResourceId.java index bfb442497b..99bce7673e 100644 --- a/src/main/java/sh/libre/scim/jpa/ScimResourceId.java +++ b/src/main/java/sh/libre/scim/jpa/ScimResourceId.java @@ -1,7 +1,6 @@ package sh.libre.scim.jpa; import org.apache.commons.lang3.StringUtils; -import sh.libre.scim.core.ScimResourceType; import java.io.Serializable; import java.util.Objects; @@ -10,13 +9,13 @@ public class ScimResourceId implements Serializable { private String id; private String realmId; private String componentId; - private ScimResourceType type; + private String type; private String externalId; public ScimResourceId() { } - public ScimResourceId(String id, String realmId, String componentId, ScimResourceType type, String externalId) { + public ScimResourceId(String id, String realmId, String componentId, String type, String externalId) { this.setId(id); this.setRealmId(realmId); this.setComponentId(componentId); @@ -48,11 +47,11 @@ public class ScimResourceId implements Serializable { this.componentId = componentId; } - public ScimResourceType getType() { + public String getType() { return type; } - public void setType(ScimResourceType type) { + public void setType(String type) { this.type = type; } @@ -75,7 +74,7 @@ public class ScimResourceId implements Serializable { return (StringUtils.equals(o.id, id) && StringUtils.equals(o.realmId, realmId) && StringUtils.equals(o.componentId, componentId) && - Objects.equals(o.type, type) && + StringUtils.equals(o.type, type) && StringUtils.equals(o.externalId, externalId)); }