use long for primary key
This commit is contained in:
parent
7437af0131
commit
1963e94e33
9 changed files with 48 additions and 54 deletions
|
@ -8,6 +8,7 @@ import org.keycloak.models.SocialLinkModel;
|
||||||
import org.keycloak.models.UserCredentialModel;
|
import org.keycloak.models.UserCredentialModel;
|
||||||
import org.keycloak.models.UserModel;
|
import org.keycloak.models.UserModel;
|
||||||
import org.keycloak.models.UserProvider;
|
import org.keycloak.models.UserProvider;
|
||||||
|
import org.keycloak.models.jpa.entities.CredentialEntity;
|
||||||
import org.keycloak.models.jpa.entities.RealmEntity;
|
import org.keycloak.models.jpa.entities.RealmEntity;
|
||||||
import org.keycloak.models.jpa.entities.RoleEntity;
|
import org.keycloak.models.jpa.entities.RoleEntity;
|
||||||
import org.keycloak.models.jpa.entities.SocialLinkEntity;
|
import org.keycloak.models.jpa.entities.SocialLinkEntity;
|
||||||
|
@ -124,9 +125,14 @@ public class JpaUserProvider implements UserProvider {
|
||||||
@Override
|
@Override
|
||||||
public void preRemove(RealmModel realm) {
|
public void preRemove(RealmModel realm) {
|
||||||
RealmEntity realmEntity = em.getReference(RealmEntity.class, realm.getId());
|
RealmEntity realmEntity = em.getReference(RealmEntity.class, realm.getId());
|
||||||
for (UserEntity u : em.createQuery("from UserEntity u where u.realm = :realm", UserEntity.class).setParameter("realm", realmEntity).getResultList()) {
|
int num = em.createQuery("delete from " + UserRoleMappingEntity.class.getSimpleName() + " mapping where mapping.user IN (select u from UserEntity u where realm=:realm)")
|
||||||
removeUser(realm, u.getUsername());
|
.setParameter("realm", realmEntity).executeUpdate();
|
||||||
}
|
num = em.createQuery("delete from " + SocialLinkEntity.class.getSimpleName() + " socialLink where socialLink.user IN (select u from UserEntity u where realm=:realm)")
|
||||||
|
.setParameter("realm", realmEntity).executeUpdate();
|
||||||
|
num = em.createQuery("delete from " + CredentialEntity.class.getSimpleName() + " mapping where mapping.user IN (select u from UserEntity u where realm=:realm)")
|
||||||
|
.setParameter("realm", realmEntity).executeUpdate();
|
||||||
|
num = em.createQuery("delete from UserEntity u where u.realm = :realm")
|
||||||
|
.setParameter("realm", realmEntity).executeUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -14,19 +14,17 @@ import org.hibernate.annotations.GenericGenerator;
|
||||||
public class AuthenticationLinkEntity {
|
public class AuthenticationLinkEntity {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@Column(length = 36)
|
@GeneratedValue
|
||||||
@GenericGenerator(name="keycloak_generator", strategy="org.keycloak.models.jpa.utils.JpaIdGenerator")
|
protected long id;
|
||||||
@GeneratedValue(generator = "keycloak_generator")
|
|
||||||
private String id;
|
|
||||||
|
|
||||||
protected String authProvider;
|
protected String authProvider;
|
||||||
protected String authUserId;
|
protected String authUserId;
|
||||||
|
|
||||||
public String getId() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(String id) {
|
public void setId(long id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,10 +21,8 @@ import java.util.Map;
|
||||||
public class AuthenticationProviderEntity {
|
public class AuthenticationProviderEntity {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@Column(length = 36)
|
@GeneratedValue
|
||||||
@GenericGenerator(name="keycloak_generator", strategy="org.keycloak.models.jpa.utils.JpaIdGenerator")
|
protected long id;
|
||||||
@GeneratedValue(generator = "keycloak_generator")
|
|
||||||
protected String id;
|
|
||||||
|
|
||||||
private String providerName;
|
private String providerName;
|
||||||
private boolean passwordUpdateSupported;
|
private boolean passwordUpdateSupported;
|
||||||
|
@ -38,11 +36,11 @@ public class AuthenticationProviderEntity {
|
||||||
})
|
})
|
||||||
private Map<String, String> config;
|
private Map<String, String> config;
|
||||||
|
|
||||||
public String getId() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(String id) {
|
public void setId(long id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import javax.persistence.Entity;
|
||||||
import javax.persistence.FetchType;
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.NamedQueries;
|
import javax.persistence.NamedQueries;
|
||||||
import javax.persistence.NamedQuery;
|
import javax.persistence.NamedQuery;
|
||||||
|
@ -21,10 +22,8 @@ import org.hibernate.annotations.GenericGenerator;
|
||||||
@Entity
|
@Entity
|
||||||
public class CredentialEntity {
|
public class CredentialEntity {
|
||||||
@Id
|
@Id
|
||||||
@Column(length = 36)
|
@GeneratedValue
|
||||||
@GenericGenerator(name="keycloak_generator", strategy="org.keycloak.models.jpa.utils.JpaIdGenerator")
|
protected long id;
|
||||||
@GeneratedValue(generator = "keycloak_generator")
|
|
||||||
protected String id;
|
|
||||||
|
|
||||||
protected String type;
|
protected String type;
|
||||||
protected String value;
|
protected String value;
|
||||||
|
@ -33,10 +32,16 @@ public class CredentialEntity {
|
||||||
protected int hashIterations;
|
protected int hashIterations;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
|
@JoinColumn(name="userId")
|
||||||
protected UserEntity user;
|
protected UserEntity user;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
public long getId() {
|
||||||
protected RealmEntity realm;
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return value;
|
return value;
|
||||||
|
@ -54,14 +59,6 @@ public class CredentialEntity {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(String id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDevice() {
|
public String getDevice() {
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,21 +14,19 @@ import org.hibernate.annotations.GenericGenerator;
|
||||||
@Entity
|
@Entity
|
||||||
public class RequiredCredentialEntity {
|
public class RequiredCredentialEntity {
|
||||||
@Id
|
@Id
|
||||||
@Column(length = 36)
|
@GeneratedValue
|
||||||
@GenericGenerator(name="keycloak_generator", strategy="org.keycloak.models.jpa.utils.JpaIdGenerator")
|
protected long id;
|
||||||
@GeneratedValue(generator = "keycloak_generator")
|
|
||||||
protected String id;
|
|
||||||
|
|
||||||
protected String type;
|
protected String type;
|
||||||
protected boolean input;
|
protected boolean input;
|
||||||
protected boolean secret;
|
protected boolean secret;
|
||||||
protected String formLabel;
|
protected String formLabel;
|
||||||
|
|
||||||
public String getId() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(String id) {
|
public void setId(long id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,10 +24,9 @@ import javax.persistence.NamedQuery;
|
||||||
@Entity
|
@Entity
|
||||||
public class ScopeMappingEntity {
|
public class ScopeMappingEntity {
|
||||||
@Id
|
@Id
|
||||||
@Column(length = 36)
|
@GeneratedValue
|
||||||
@GenericGenerator(name="keycloak_generator", strategy="org.keycloak.models.jpa.utils.JpaIdGenerator")
|
protected long id;
|
||||||
@GeneratedValue(generator = "keycloak_generator")
|
|
||||||
protected String id;
|
|
||||||
@ManyToOne(fetch= FetchType.LAZY)
|
@ManyToOne(fetch= FetchType.LAZY)
|
||||||
protected ClientEntity client;
|
protected ClientEntity client;
|
||||||
|
|
||||||
|
@ -35,11 +34,11 @@ public class ScopeMappingEntity {
|
||||||
@JoinColumn(name="roleId")
|
@JoinColumn(name="roleId")
|
||||||
protected RoleEntity role;
|
protected RoleEntity role;
|
||||||
|
|
||||||
public String getId() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(String id) {
|
public void setId(long id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,8 @@ import org.hibernate.annotations.GenericGenerator;
|
||||||
@Entity
|
@Entity
|
||||||
public class SocialLinkEntity {
|
public class SocialLinkEntity {
|
||||||
@Id
|
@Id
|
||||||
@Column(length = 36)
|
@GeneratedValue
|
||||||
@GenericGenerator(name="keycloak_generator", strategy="org.keycloak.models.jpa.utils.JpaIdGenerator")
|
protected long id;
|
||||||
@GeneratedValue(generator = "keycloak_generator")
|
|
||||||
private String id;
|
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
private UserEntity user;
|
private UserEntity user;
|
||||||
|
@ -38,11 +36,11 @@ public class SocialLinkEntity {
|
||||||
protected String socialUserId;
|
protected String socialUserId;
|
||||||
protected String socialUsername;
|
protected String socialUsername;
|
||||||
|
|
||||||
public String getId() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(String id) {
|
public void setId(long id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class UserEntity {
|
||||||
@CollectionTable
|
@CollectionTable
|
||||||
protected Set<UserModel.RequiredAction> requiredActions = new HashSet<UserModel.RequiredAction>();
|
protected Set<UserModel.RequiredAction> requiredActions = new HashSet<UserModel.RequiredAction>();
|
||||||
|
|
||||||
@OneToMany(cascade = CascadeType.REMOVE, orphanRemoval = true)
|
@OneToMany(cascade = CascadeType.REMOVE, orphanRemoval = true, mappedBy="user")
|
||||||
protected Collection<CredentialEntity> credentials = new ArrayList<CredentialEntity>();
|
protected Collection<CredentialEntity> credentials = new ArrayList<CredentialEntity>();
|
||||||
|
|
||||||
@OneToOne(cascade = CascadeType.REMOVE, orphanRemoval = true)
|
@OneToOne(cascade = CascadeType.REMOVE, orphanRemoval = true)
|
||||||
|
|
|
@ -24,22 +24,22 @@ import org.hibernate.annotations.GenericGenerator;
|
||||||
@Entity
|
@Entity
|
||||||
public class UserRoleMappingEntity {
|
public class UserRoleMappingEntity {
|
||||||
@Id
|
@Id
|
||||||
@Column(length = 36)
|
@GeneratedValue
|
||||||
@GenericGenerator(name="keycloak_generator", strategy="org.keycloak.models.jpa.utils.JpaIdGenerator")
|
protected long id;
|
||||||
@GeneratedValue(generator = "keycloak_generator")
|
|
||||||
protected String id;
|
|
||||||
@ManyToOne(fetch= FetchType.LAZY)
|
@ManyToOne(fetch= FetchType.LAZY)
|
||||||
|
@JoinColumn(name="userId")
|
||||||
protected UserEntity user;
|
protected UserEntity user;
|
||||||
|
|
||||||
@ManyToOne(fetch= FetchType.LAZY)
|
@ManyToOne(fetch= FetchType.LAZY)
|
||||||
@JoinColumn(name="roleId")
|
@JoinColumn(name="roleId")
|
||||||
protected RoleEntity role;
|
protected RoleEntity role;
|
||||||
|
|
||||||
public String getId() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(String id) {
|
public void setId(long id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue