diff --git a/audit/jpa/src/main/java/org/keycloak/audit/jpa/EventEntity.java b/audit/jpa/src/main/java/org/keycloak/audit/jpa/EventEntity.java
index f191813248..4593d2e673 100644
--- a/audit/jpa/src/main/java/org/keycloak/audit/jpa/EventEntity.java
+++ b/audit/jpa/src/main/java/org/keycloak/audit/jpa/EventEntity.java
@@ -11,6 +11,7 @@ import javax.persistence.Id;
public class EventEntity {
@Id
+ @Column(length = 36)
private String id;
private long time;
diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/AuthenticationLinkEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/AuthenticationLinkEntity.java
index 16942d9b30..fa233bb0be 100755
--- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/AuthenticationLinkEntity.java
+++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/AuthenticationLinkEntity.java
@@ -1,11 +1,12 @@
package org.keycloak.models.jpa.entities;
-import org.hibernate.annotations.GenericGenerator;
-
+import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
+import org.hibernate.annotations.GenericGenerator;
+
/**
* @author Marek Posolda
*/
@@ -13,6 +14,7 @@ import javax.persistence.Id;
public class AuthenticationLinkEntity {
@Id
+ @Column(length = 36)
@GenericGenerator(name="keycloak_generator", strategy="org.keycloak.models.jpa.utils.JpaIdGenerator")
@GeneratedValue(generator = "keycloak_generator")
private String id;
diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/AuthenticationProviderEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/AuthenticationProviderEntity.java
index 06094a2ff1..1efd4564ac 100755
--- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/AuthenticationProviderEntity.java
+++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/AuthenticationProviderEntity.java
@@ -21,6 +21,7 @@ import java.util.Map;
public class AuthenticationProviderEntity {
@Id
+ @Column(length = 36)
@GenericGenerator(name="keycloak_generator", strategy="org.keycloak.models.jpa.utils.JpaIdGenerator")
@GeneratedValue(generator = "keycloak_generator")
protected String id;
diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ClientEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ClientEntity.java
index 46b819778e..cb661e7312 100755
--- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ClientEntity.java
+++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ClientEntity.java
@@ -24,6 +24,7 @@ import java.util.Set;
@Table(uniqueConstraints = {@UniqueConstraint(columnNames = {"realm", "name"})})
public abstract class ClientEntity {
@Id
+ @Column(length = 36)
private String id;
@Column(name = "name")
private String name;
diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/CredentialEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/CredentialEntity.java
index 2a03cdf997..71824338d7 100755
--- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/CredentialEntity.java
+++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/CredentialEntity.java
@@ -1,7 +1,6 @@
package org.keycloak.models.jpa.entities;
-import org.hibernate.annotations.GenericGenerator;
-
+import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
@@ -10,6 +9,8 @@ import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
+import org.hibernate.annotations.GenericGenerator;
+
/**
* @author Bill Burke
* @version $Revision: 1 $
@@ -20,6 +21,7 @@ import javax.persistence.NamedQuery;
@Entity
public class CredentialEntity {
@Id
+ @Column(length = 36)
@GenericGenerator(name="keycloak_generator", strategy="org.keycloak.models.jpa.utils.JpaIdGenerator")
@GeneratedValue(generator = "keycloak_generator")
protected String id;
diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RealmEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RealmEntity.java
index 8fd8a5660a..a7d9b319b6 100755
--- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RealmEntity.java
+++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RealmEntity.java
@@ -33,6 +33,7 @@ import java.util.Set;
})
public class RealmEntity {
@Id
+ @Column(length = 36)
protected String id;
@Column(unique = true)
diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RequiredCredentialEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RequiredCredentialEntity.java
index bc07b01d10..3214e0b779 100755
--- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RequiredCredentialEntity.java
+++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RequiredCredentialEntity.java
@@ -1,11 +1,12 @@
package org.keycloak.models.jpa.entities;
-import org.hibernate.annotations.GenericGenerator;
-
+import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
+import org.hibernate.annotations.GenericGenerator;
+
/**
* @author Bill Burke
* @version $Revision: 1 $
@@ -13,6 +14,7 @@ import javax.persistence.Id;
@Entity
public class RequiredCredentialEntity {
@Id
+ @Column(length = 36)
@GenericGenerator(name="keycloak_generator", strategy="org.keycloak.models.jpa.utils.JpaIdGenerator")
@GeneratedValue(generator = "keycloak_generator")
protected String id;
diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RoleEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RoleEntity.java
index 2c62502793..eff55f4ee2 100755
--- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RoleEntity.java
+++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RoleEntity.java
@@ -30,7 +30,7 @@ import java.util.Collection;
public class RoleEntity {
@Id
- @Column(name="id")
+ @Column(name="id", length = 36)
private String id;
private String name;
@@ -51,6 +51,7 @@ public class RoleEntity {
private ApplicationEntity application;
// Hack to ensure that either name+application or name+realm are unique. Needed due to MS-SQL as it don't allow multiple NULL values in the column, which is part of constraint
+ @Column(length = 36)
private String appRealmConstraint;
@ManyToMany(fetch = FetchType.LAZY, cascade = {})
diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ScopeMappingEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ScopeMappingEntity.java
index b45b69b8e4..6972e435b4 100755
--- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ScopeMappingEntity.java
+++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ScopeMappingEntity.java
@@ -2,6 +2,7 @@ package org.keycloak.models.jpa.entities;
import org.hibernate.annotations.GenericGenerator;
+import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
@@ -23,6 +24,7 @@ import javax.persistence.NamedQuery;
@Entity
public class ScopeMappingEntity {
@Id
+ @Column(length = 36)
@GenericGenerator(name="keycloak_generator", strategy="org.keycloak.models.jpa.utils.JpaIdGenerator")
@GeneratedValue(generator = "keycloak_generator")
protected String id;
diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/SocialLinkEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/SocialLinkEntity.java
index 5e63b5155a..ece95bb1b2 100755
--- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/SocialLinkEntity.java
+++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/SocialLinkEntity.java
@@ -1,7 +1,6 @@
package org.keycloak.models.jpa.entities;
-import org.hibernate.annotations.GenericGenerator;
-
+import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
@@ -10,6 +9,8 @@ import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
+import org.hibernate.annotations.GenericGenerator;
+
/**
* @author Bill Burke
* @version $Revision: 1 $
@@ -22,6 +23,7 @@ import javax.persistence.NamedQuery;
@Entity
public class SocialLinkEntity {
@Id
+ @Column(length = 36)
@GenericGenerator(name="keycloak_generator", strategy="org.keycloak.models.jpa.utils.JpaIdGenerator")
@GeneratedValue(generator = "keycloak_generator")
private String id;
diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserEntity.java
index 53561f9238..23299807c3 100755
--- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserEntity.java
+++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserEntity.java
@@ -44,6 +44,7 @@ import java.util.Set;
})
public class UserEntity {
@Id
+ @Column(length = 36)
protected String id;
protected String username;
diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserRoleMappingEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserRoleMappingEntity.java
index 27b8f49bd5..54b8a47aa5 100755
--- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserRoleMappingEntity.java
+++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserRoleMappingEntity.java
@@ -1,7 +1,6 @@
package org.keycloak.models.jpa.entities;
-import org.hibernate.annotations.GenericGenerator;
-
+import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
@@ -11,6 +10,8 @@ import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
+import org.hibernate.annotations.GenericGenerator;
+
/**
* @author Bill Burke
* @version $Revision: 1 $
@@ -23,6 +24,7 @@ import javax.persistence.NamedQuery;
@Entity
public class UserRoleMappingEntity {
@Id
+ @Column(length = 36)
@GenericGenerator(name="keycloak_generator", strategy="org.keycloak.models.jpa.utils.JpaIdGenerator")
@GeneratedValue(generator = "keycloak_generator")
protected String id;
diff --git a/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/ClientUserSessionAssociationEntity.java b/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/ClientUserSessionAssociationEntity.java
index 69340b0144..9d6ab872bf 100755
--- a/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/ClientUserSessionAssociationEntity.java
+++ b/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/ClientUserSessionAssociationEntity.java
@@ -1,5 +1,6 @@
package org.keycloak.models.sessions.jpa.entities;
+import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
@@ -30,6 +31,7 @@ public class ClientUserSessionAssociationEntity {
protected UserSessionEntity session;
@Id
+ @Column(length = 36)
protected String clientId;
public UserSessionEntity getSession() {
diff --git a/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/UsernameLoginFailureEntity.java b/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/UsernameLoginFailureEntity.java
index fac93752e8..fcafcc31cd 100755
--- a/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/UsernameLoginFailureEntity.java
+++ b/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/UsernameLoginFailureEntity.java
@@ -1,5 +1,6 @@
package org.keycloak.models.sessions.jpa.entities;
+import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
@@ -21,9 +22,11 @@ import java.io.Serializable;
public class UsernameLoginFailureEntity {
@Id
+ @Column(length = 200)
protected String username;
@Id
+ @Column(length = 36)
protected String realmId;
protected int failedLoginNotBefore;