diff --git a/src/main/java/sh/libre/scim/jpa/ScimResource.java b/src/main/java/sh/libre/scim/jpa/ScimResource.java
index 5536a6dd965cc447057738dab647a8813a600332..cacc92e81d7b63fcd142faf35435ddfbd504948b 100644
--- a/src/main/java/sh/libre/scim/jpa/ScimResource.java
+++ b/src/main/java/sh/libre/scim/jpa/ScimResource.java
@@ -9,6 +9,7 @@ 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)
@@ -33,7 +34,7 @@ public class ScimResource {
 
     @Id
     @Column(name = "TYPE", nullable = false)
-    private String type;
+    private ScimResourceType type;
 
     @Id
     @Column(name = "EXTERNAL_ID", nullable = false)
@@ -71,11 +72,11 @@ public class ScimResource {
         this.externalId = externalId;
     }
 
-    public String getType() {
+    public ScimResourceType getType() {
         return type;
     }
 
-    public void setType(String type) {
+    public void setType(ScimResourceType 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 7d96b2819d42b320a6f026b47b1b4d5046170d0b..02a473cb67ee153f811e14b33be040c156ef9b49 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.name());
+        entity.setType(type);
         entity.setExternalId(externalId.asString());
         entity.setComponentId(componentId);
         entity.setRealmId(realmId);
@@ -56,7 +56,7 @@ public class ScimResourceDao {
     private TypedQuery<ScimResource> getScimResourceTypedQuery(String queryName, String id, ScimResourceType type) {
         return getEntityManager()
                 .createNamedQuery(queryName, ScimResource.class)
-                .setParameter("type", type.name())
+                .setParameter("type", type)
                 .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 99bce7673edec14240cfb0f94f7b3247b2a50eb7..bfb442497bade90cdf1633fde558ecbdc69a32dd 100644
--- a/src/main/java/sh/libre/scim/jpa/ScimResourceId.java
+++ b/src/main/java/sh/libre/scim/jpa/ScimResourceId.java
@@ -1,6 +1,7 @@
 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;
@@ -9,13 +10,13 @@ public class ScimResourceId implements Serializable {
     private String id;
     private String realmId;
     private String componentId;
-    private String type;
+    private ScimResourceType type;
     private String externalId;
 
     public ScimResourceId() {
     }
 
-    public ScimResourceId(String id, String realmId, String componentId, String type, String externalId) {
+    public ScimResourceId(String id, String realmId, String componentId, ScimResourceType type, String externalId) {
         this.setId(id);
         this.setRealmId(realmId);
         this.setComponentId(componentId);
@@ -47,11 +48,11 @@ public class ScimResourceId implements Serializable {
         this.componentId = componentId;
     }
 
-    public String getType() {
+    public ScimResourceType getType() {
         return type;
     }
 
-    public void setType(String type) {
+    public void setType(ScimResourceType type) {
         this.type = type;
     }
 
@@ -74,7 +75,7 @@ public class ScimResourceId implements Serializable {
         return (StringUtils.equals(o.id, id) &&
                 StringUtils.equals(o.realmId, realmId) &&
                 StringUtils.equals(o.componentId, componentId) &&
-                StringUtils.equals(o.type, type) &&
+                Objects.equals(o.type, type) &&
                 StringUtils.equals(o.externalId, externalId));
     }