[KEYCLOAK-14335] - Not initializing entity associations and removing bi-directional ones

Co-authored-by: Stian Thorgersen <stian@redhat.com>
Co-authored-by: Hynek Mlnarik <hmlnarik@redhat.com>
This commit is contained in:
Pedro Igor 2020-06-02 09:56:40 -03:00
parent a121f77ea4
commit 0870041b0b
11 changed files with 182 additions and 72 deletions

View file

@ -151,7 +151,7 @@ public class JpaRealmProvider implements RealmProvider {
em.flush();
int num = em.createNamedQuery("deleteGroupRoleMappingsByRealm")
.setParameter("realm", realm).executeUpdate();
.setParameter("realm", realm.getId()).executeUpdate();
TypedQuery<String> query = em.createNamedQuery("getClientIdsByRealm", String.class);
query.setParameter("realm", realm.getId());
@ -407,7 +407,7 @@ public class JpaRealmProvider implements RealmProvider {
public GroupModel getGroupById(String id, RealmModel realm) {
GroupEntity groupEntity = em.find(GroupEntity.class, id);
if (groupEntity == null) return null;
if (!groupEntity.getRealm().getId().equals(realm.getId())) return null;
if (!groupEntity.getRealm().equals(realm.getId())) return null;
GroupAdapter adapter = new GroupAdapter(realm, em, groupEntity);
return adapter;
}
@ -543,7 +543,7 @@ public class JpaRealmProvider implements RealmProvider {
session.realms().removeGroup(realm, subGroup);
}
GroupEntity groupEntity = em.find(GroupEntity.class, group.getId(), LockModeType.PESSIMISTIC_WRITE);
if ((groupEntity == null) || (!groupEntity.getRealm().getId().equals(realm.getId()))) {
if ((groupEntity == null) || (!groupEntity.getRealm().equals(realm.getId()))) {
return false;
}
em.createNamedQuery("deleteGroupRoleMappingsByGroup").setParameter("group", groupEntity).executeUpdate();
@ -569,7 +569,7 @@ public class JpaRealmProvider implements RealmProvider {
groupEntity.setId(id);
groupEntity.setName(name);
RealmEntity realmEntity = em.getReference(RealmEntity.class, realm.getId());
groupEntity.setRealm(realmEntity);
groupEntity.setRealm(realmEntity.getId());
groupEntity.setParentId(toParent == null? GroupEntity.TOP_PARENT_ID : toParent.getId());
em.persist(groupEntity);
em.flush();

View file

@ -1229,7 +1229,11 @@ public class RealmAdapter implements RealmModel, JpaModel<RealmEntity> {
@Override
public ClientModel getMasterAdminClient() {
ClientEntity masterAdminClient = realm.getMasterAdminClient();
String masterAdminClientId = realm.getMasterAdminClient();
if (masterAdminClientId == null) {
return null;
}
ClientEntity masterAdminClient = em.find(ClientEntity.class, masterAdminClientId);
if (masterAdminClient == null) {
return null;
}
@ -1245,8 +1249,8 @@ public class RealmAdapter implements RealmModel, JpaModel<RealmEntity> {
@Override
public void setMasterAdminClient(ClientModel client) {
ClientEntity appEntity = client !=null ? em.getReference(ClientEntity.class, client.getId()) : null;
realm.setMasterAdminClient(appEntity);
String appEntityId = client !=null ? em.getReference(ClientEntity.class, client.getId()).getId() : null;
realm.setMasterAdminClient(appEntityId);
em.flush();
}

View file

@ -28,12 +28,10 @@ import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
/**
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
@ -69,7 +67,7 @@ public class AuthenticationFlowEntity {
@OneToMany(fetch = FetchType.LAZY, cascade ={CascadeType.REMOVE}, orphanRemoval = true, mappedBy = "parentFlow")
Collection<AuthenticationExecutionEntity> executions = new ArrayList<AuthenticationExecutionEntity>();
Collection<AuthenticationExecutionEntity> executions;
public String getId() {
return id;
}
@ -103,6 +101,9 @@ public class AuthenticationFlowEntity {
}
public Collection<AuthenticationExecutionEntity> getExecutions() {
if (executions == null) {
executions = new LinkedList<>();
}
return executions;
}

View file

@ -37,10 +37,10 @@ import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
@ -102,24 +102,24 @@ public class ClientEntity {
@ElementCollection
@Column(name="VALUE")
@CollectionTable(name = "WEB_ORIGINS", joinColumns={ @JoinColumn(name="CLIENT_ID") })
protected Set<String> webOrigins = new HashSet<String>();
protected Set<String> webOrigins;
@ElementCollection
@Column(name="VALUE")
@CollectionTable(name = "REDIRECT_URIS", joinColumns={ @JoinColumn(name="CLIENT_ID") })
protected Set<String> redirectUris = new HashSet<String>();
protected Set<String> redirectUris;
@OneToMany(cascade ={CascadeType.REMOVE}, orphanRemoval = true, mappedBy = "client")
protected Collection<ClientAttributeEntity> attributes = new ArrayList<>();
protected Collection<ClientAttributeEntity> attributes;
@ElementCollection
@MapKeyColumn(name="BINDING_NAME")
@Column(name="FLOW_ID", length = 4000)
@CollectionTable(name="CLIENT_AUTH_FLOW_BINDINGS", joinColumns={ @JoinColumn(name="CLIENT_ID") })
protected Map<String, String> authFlowBindings = new HashMap<String, String>();
protected Map<String, String> authFlowBindings;
@OneToMany(cascade ={CascadeType.REMOVE}, orphanRemoval = true, mappedBy = "client")
Collection<ProtocolMapperEntity> protocolMappers = new ArrayList<ProtocolMapperEntity>();
Collection<ProtocolMapperEntity> protocolMappers;
@Column(name="SURROGATE_AUTH_REQUIRED")
private boolean surrogateAuthRequired;
@ -156,17 +156,17 @@ public class ClientEntity {
@OneToMany(fetch = FetchType.LAZY, cascade ={CascadeType.REMOVE}, orphanRemoval = true)
@JoinTable(name="CLIENT_DEFAULT_ROLES", joinColumns = { @JoinColumn(name="CLIENT_ID")}, inverseJoinColumns = { @JoinColumn(name="ROLE_ID")})
Collection<RoleEntity> defaultRoles = new ArrayList<RoleEntity>();
Collection<RoleEntity> defaultRoles;
@OneToMany(fetch = FetchType.LAZY)
@JoinTable(name="SCOPE_MAPPING", joinColumns = { @JoinColumn(name="CLIENT_ID")}, inverseJoinColumns = { @JoinColumn(name="ROLE_ID")})
protected Set<RoleEntity> scopeMapping = new HashSet<>();
protected Set<RoleEntity> scopeMapping;
@ElementCollection
@MapKeyColumn(name="NAME")
@Column(name="VALUE")
@CollectionTable(name="CLIENT_NODE_REGISTRATIONS", joinColumns={ @JoinColumn(name="CLIENT_ID") })
Map<String, Integer> registeredNodes = new HashMap<String, Integer>();
Map<String, Integer> registeredNodes;
public RealmEntity getRealm() {
return realm;
@ -225,6 +225,9 @@ public class ClientEntity {
}
public Set<String> getWebOrigins() {
if (webOrigins == null) {
webOrigins = new HashSet<>();
}
return webOrigins;
}
@ -233,6 +236,9 @@ public class ClientEntity {
}
public Set<String> getRedirectUris() {
if (redirectUris == null) {
redirectUris = new HashSet<>();
}
return redirectUris;
}
@ -289,6 +295,9 @@ public class ClientEntity {
}
public Collection<ClientAttributeEntity> getAttributes() {
if (attributes == null) {
attributes = new LinkedList<>();
}
return attributes;
}
@ -297,6 +306,9 @@ public class ClientEntity {
}
public Map<String, String> getAuthFlowBindings() {
if (authFlowBindings == null) {
authFlowBindings = new HashMap<>();
}
return authFlowBindings;
}
@ -321,6 +333,9 @@ public class ClientEntity {
}
public Collection<ProtocolMapperEntity> getProtocolMappers() {
if (protocolMappers == null) {
protocolMappers = new LinkedList<>();
}
return protocolMappers;
}
@ -361,6 +376,9 @@ public class ClientEntity {
}
public Collection<RoleEntity> getDefaultRoles() {
if (defaultRoles == null) {
defaultRoles = new LinkedList<>();
}
return defaultRoles;
}
@ -425,6 +443,9 @@ public class ClientEntity {
}
public Map<String, Integer> getRegisteredNodes() {
if (registeredNodes == null) {
registeredNodes = new HashMap<>();
}
return registeredNodes;
}
@ -433,6 +454,9 @@ public class ClientEntity {
}
public Set<RoleEntity> getScopeMapping() {
if (scopeMapping == null) {
scopeMapping = new HashSet<>();
}
return scopeMapping;
}

View file

@ -31,8 +31,8 @@ import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
/**
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
@ -52,7 +52,7 @@ public class ClientScopeEntity {
@Column(name = "DESCRIPTION")
private String description;
@OneToMany(cascade ={CascadeType.REMOVE}, orphanRemoval = true, mappedBy = "clientScope")
Collection<ProtocolMapperEntity> protocolMappers = new ArrayList<ProtocolMapperEntity>();
Collection<ProtocolMapperEntity> protocolMappers;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "REALM_ID")
protected RealmEntity realm;
@ -62,7 +62,7 @@ public class ClientScopeEntity {
@OneToMany(cascade ={CascadeType.REMOVE}, orphanRemoval = true, mappedBy = "clientScope")
protected Collection<ClientScopeAttributeEntity> attributes = new ArrayList<>();
protected Collection<ClientScopeAttributeEntity> attributes;
public RealmEntity getRealm() {
return realm;
@ -97,6 +97,9 @@ public class ClientScopeEntity {
}
public Collection<ProtocolMapperEntity> getProtocolMappers() {
if (protocolMappers == null) {
protocolMappers = new LinkedList<>();
}
return protocolMappers;
}
@ -113,6 +116,9 @@ public class ClientScopeEntity {
}
public Collection<ClientScopeAttributeEntity> getAttributes() {
if (attributes == null) {
attributes = new LinkedList<>();
}
return attributes;
}

View file

@ -64,7 +64,7 @@ public class ComponentEntity {
protected String subType;
@OneToMany(fetch = FetchType.LAZY, cascade ={ CascadeType.ALL}, orphanRemoval = true, mappedBy = "component")
Set<ComponentConfigEntity> componentConfigs = new HashSet<>();
Set<ComponentConfigEntity> componentConfigs;
public String getId() {
return id;
@ -123,6 +123,9 @@ public class ComponentEntity {
}
public Set<ComponentConfigEntity> getComponentConfigs() {
if (componentConfigs == null) {
componentConfigs = new HashSet<>();
}
return componentConfigs;
}

View file

@ -20,8 +20,8 @@ package org.keycloak.models.jpa.entities;
import org.hibernate.annotations.Nationalized;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
/**
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
@ -29,10 +29,10 @@ import java.util.Collection;
*/
@NamedQueries({
@NamedQuery(name="getGroupIdsByParent", query="select u.id from GroupEntity u where u.parentId = :parent"),
@NamedQuery(name="getGroupIdsByNameContaining", query="select u.id from GroupEntity u where u.realm.id = :realm and u.name like concat('%',:search,'%') order by u.name ASC"),
@NamedQuery(name="getTopLevelGroupIds", query="select u.id from GroupEntity u where u.parentId = :parent and u.realm.id = :realm order by u.name ASC"),
@NamedQuery(name="getGroupCount", query="select count(u) from GroupEntity u where u.realm.id = :realm"),
@NamedQuery(name="getTopLevelGroupCount", query="select count(u) from GroupEntity u where u.realm.id = :realm and u.parentId = :parent")
@NamedQuery(name="getGroupIdsByNameContaining", query="select u.id from GroupEntity u where u.realm = :realm and u.name like concat('%',:search,'%') order by u.name ASC"),
@NamedQuery(name="getTopLevelGroupIds", query="select u.id from GroupEntity u where u.parentId = :parent and u.realm = :realm order by u.name ASC"),
@NamedQuery(name="getGroupCount", query="select count(u) from GroupEntity u where u.realm = :realm"),
@NamedQuery(name="getTopLevelGroupCount", query="select count(u) from GroupEntity u where u.realm = :realm and u.parentId = :parent")
})
@Entity
@Table(name="KEYCLOAK_GROUP",
@ -57,14 +57,13 @@ public class GroupEntity {
@Column(name = "PARENT_GROUP")
private String parentId;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "REALM_ID")
private RealmEntity realm;
@Column(name = "REALM_ID")
private String realm;
@OneToMany(
cascade = CascadeType.REMOVE,
orphanRemoval = true, mappedBy="group")
protected Collection<GroupAttributeEntity> attributes = new ArrayList<GroupAttributeEntity>();
protected Collection<GroupAttributeEntity> attributes;
public String getId() {
return id;
@ -75,6 +74,9 @@ public class GroupEntity {
}
public Collection<GroupAttributeEntity> getAttributes() {
if (attributes == null) {
attributes = new LinkedList<>();
}
return attributes;
}
@ -90,11 +92,11 @@ public class GroupEntity {
this.name = name;
}
public RealmEntity getRealm() {
public String getRealm() {
return realm;
}
public void setRealm(RealmEntity realm) {
public void setRealm(String realm) {
this.realm = realm;
}

View file

@ -32,12 +32,11 @@ import javax.persistence.MapKeyColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -138,36 +137,36 @@ public class RealmEntity {
protected String emailTheme;
@OneToMany(cascade ={CascadeType.REMOVE}, orphanRemoval = true, mappedBy = "realm", fetch = FetchType.EAGER)
Collection<RealmAttributeEntity> attributes = new ArrayList<>();
Collection<RealmAttributeEntity> attributes;
@OneToMany(cascade ={CascadeType.REMOVE}, orphanRemoval = true, mappedBy = "realm")
Collection<RequiredCredentialEntity> requiredCredentials = new ArrayList<>();
Collection<RequiredCredentialEntity> requiredCredentials;
@OneToMany(cascade ={CascadeType.REMOVE}, orphanRemoval = true, mappedBy = "realm")
List<UserFederationProviderEntity> userFederationProviders = new ArrayList<>();
List<UserFederationProviderEntity> userFederationProviders;
@OneToMany(cascade ={CascadeType.REMOVE}, orphanRemoval = true, mappedBy = "realm")
Collection<UserFederationMapperEntity> userFederationMappers = new ArrayList<UserFederationMapperEntity>();
Collection<UserFederationMapperEntity> userFederationMappers;
@OneToMany(fetch = FetchType.LAZY, cascade ={CascadeType.REMOVE}, orphanRemoval = true, mappedBy = "realm")
Collection<ClientScopeEntity> clientScopes = new ArrayList<>();
Collection<ClientScopeEntity> clientScopes;
@ElementCollection
@MapKeyColumn(name="NAME")
@Column(name="VALUE")
@CollectionTable(name="REALM_SMTP_CONFIG", joinColumns={ @JoinColumn(name="REALM_ID") })
protected Map<String, String> smtpConfig = new HashMap<String, String>();
protected Map<String, String> smtpConfig;
@OneToMany(fetch = FetchType.LAZY, cascade ={CascadeType.REMOVE}, orphanRemoval = true)
@JoinTable(name="REALM_DEFAULT_ROLES", joinColumns = { @JoinColumn(name="REALM_ID")}, inverseJoinColumns = { @JoinColumn(name="ROLE_ID")})
protected Collection<RoleEntity> defaultRoles = new ArrayList<RoleEntity>();
protected Collection<RoleEntity> defaultRoles;
@OneToMany(fetch = FetchType.LAZY, cascade ={CascadeType.REMOVE}, orphanRemoval = true)
@JoinTable(name="REALM_DEFAULT_GROUPS", joinColumns = { @JoinColumn(name="REALM_ID")}, inverseJoinColumns = { @JoinColumn(name="GROUP_ID")})
protected Collection<GroupEntity> defaultGroups = new ArrayList<>();
protected Collection<GroupEntity> defaultGroups;
@OneToMany(fetch = FetchType.LAZY, cascade ={CascadeType.REMOVE}, orphanRemoval = true, mappedBy = "realm")
protected Collection<GroupEntity> groups = new ArrayList<>();
protected Collection<GroupEntity> groups;
@Column(name="EVENTS_ENABLED")
protected boolean eventsEnabled;
@ -177,40 +176,39 @@ public class RealmEntity {
@ElementCollection
@Column(name="VALUE")
@CollectionTable(name="REALM_EVENTS_LISTENERS", joinColumns={ @JoinColumn(name="REALM_ID") })
protected Set<String> eventsListeners = new HashSet<String>();
protected Set<String> eventsListeners;
@ElementCollection
@Column(name="VALUE")
@CollectionTable(name="REALM_ENABLED_EVENT_TYPES", joinColumns={ @JoinColumn(name="REALM_ID") })
protected Set<String> enabledEventTypes = new HashSet<String>();
protected Set<String> enabledEventTypes;
@Column(name="ADMIN_EVENTS_ENABLED")
protected boolean adminEventsEnabled;
@Column(name="ADMIN_EVENTS_DETAILS_ENABLED")
protected boolean adminEventsDetailsEnabled;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name="MASTER_ADMIN_CLIENT")
protected ClientEntity masterAdminClient;
@Column(name="MASTER_ADMIN_CLIENT")
protected String masterAdminClient;
@OneToMany(cascade ={CascadeType.REMOVE}, orphanRemoval = true, mappedBy = "realm")
protected List<IdentityProviderEntity> identityProviders = new ArrayList<IdentityProviderEntity>();
protected List<IdentityProviderEntity> identityProviders;
@OneToMany(cascade ={CascadeType.REMOVE}, orphanRemoval = true, mappedBy = "realm")
Collection<IdentityProviderMapperEntity> identityProviderMappers = new ArrayList<IdentityProviderMapperEntity>();
Collection<IdentityProviderMapperEntity> identityProviderMappers;
@OneToMany(cascade ={CascadeType.REMOVE}, orphanRemoval = true, mappedBy = "realm")
Collection<AuthenticatorConfigEntity> authenticators = new ArrayList<>();
Collection<AuthenticatorConfigEntity> authenticators;
@OneToMany(cascade ={CascadeType.REMOVE}, orphanRemoval = true, mappedBy = "realm")
Collection<RequiredActionProviderEntity> requiredActionProviders = new ArrayList<>();
Collection<RequiredActionProviderEntity> requiredActionProviders;
@OneToMany(cascade ={CascadeType.REMOVE}, orphanRemoval = true, mappedBy = "realm")
Collection<AuthenticationFlowEntity> authenticationFlows = new ArrayList<>();
Collection<AuthenticationFlowEntity> authenticationFlows;
@OneToMany(fetch = FetchType.LAZY, cascade ={CascadeType.ALL}, orphanRemoval = true, mappedBy = "realm")
Set<ComponentEntity> components = new HashSet<>();
Set<ComponentEntity> components;
@Column(name="BROWSER_FLOW")
protected String browserFlow;
@ -237,7 +235,7 @@ public class RealmEntity {
@ElementCollection
@Column(name="VALUE")
@CollectionTable(name="REALM_SUPPORTED_LOCALES", joinColumns={ @JoinColumn(name="REALM_ID") })
protected Set<String> supportedLocales = new HashSet<String>();
protected Set<String> supportedLocales;
@Column(name="DEFAULT_LOCALE")
protected String defaultLocale;
@ -438,6 +436,9 @@ public class RealmEntity {
}
public Collection<RequiredCredentialEntity> getRequiredCredentials() {
if (requiredCredentials == null) {
requiredCredentials = new LinkedList<>();
}
return requiredCredentials;
}
@ -445,6 +446,9 @@ public class RealmEntity {
this.requiredCredentials = requiredCredentials;
}
public Map<String, String> getSmtpConfig() {
if (smtpConfig == null) {
smtpConfig = new HashMap<>();
}
return smtpConfig;
}
@ -453,6 +457,9 @@ public class RealmEntity {
}
public Collection<RoleEntity> getDefaultRoles() {
if (defaultRoles == null) {
defaultRoles = new LinkedList<>();
}
return defaultRoles;
}
@ -461,6 +468,9 @@ public class RealmEntity {
}
public Collection<GroupEntity> getDefaultGroups() {
if (defaultGroups == null) {
defaultGroups = new LinkedList<>();
}
return defaultGroups;
}
@ -469,6 +479,9 @@ public class RealmEntity {
}
public Collection<GroupEntity> getGroups() {
if (groups == null) {
groups = new LinkedList<>();
}
return groups;
}
@ -541,6 +554,9 @@ public class RealmEntity {
}
public Set<String> getEventsListeners() {
if (eventsListeners == null) {
eventsListeners = new HashSet<>();
}
return eventsListeners;
}
@ -549,6 +565,9 @@ public class RealmEntity {
}
public Set<String> getEnabledEventTypes() {
if (enabledEventTypes == null) {
enabledEventTypes = new HashSet<>();
}
return enabledEventTypes;
}
@ -572,15 +591,18 @@ public class RealmEntity {
this.adminEventsDetailsEnabled = adminEventsDetailsEnabled;
}
public ClientEntity getMasterAdminClient() {
public String getMasterAdminClient() {
return masterAdminClient;
}
public void setMasterAdminClient(ClientEntity masterAdminClient) {
public void setMasterAdminClient(String masterAdminClient) {
this.masterAdminClient = masterAdminClient;
}
public List<UserFederationProviderEntity> getUserFederationProviders() {
if (userFederationProviders == null) {
userFederationProviders = new LinkedList<>();
}
return userFederationProviders;
}
@ -589,6 +611,9 @@ public class RealmEntity {
}
public Collection<UserFederationMapperEntity> getUserFederationMappers() {
if (userFederationMappers == null) {
userFederationMappers = new LinkedList<>();
}
return userFederationMappers;
}
@ -597,6 +622,9 @@ public class RealmEntity {
}
public Collection<RealmAttributeEntity> getAttributes() {
if (attributes == null) {
attributes = new LinkedList<>();
}
return attributes;
}
@ -605,6 +633,9 @@ public class RealmEntity {
}
public List<IdentityProviderEntity> getIdentityProviders() {
if (identityProviders == null) {
identityProviders = new LinkedList<>();
}
return this.identityProviders;
}
@ -626,6 +657,9 @@ public class RealmEntity {
}
public Set<String> getSupportedLocales() {
if (supportedLocales == null) {
supportedLocales = new HashSet<>();
}
return supportedLocales;
}
@ -642,6 +676,9 @@ public class RealmEntity {
}
public Collection<IdentityProviderMapperEntity> getIdentityProviderMappers() {
if (identityProviderMappers == null) {
identityProviderMappers = new LinkedList<>();
}
return identityProviderMappers;
}
@ -650,14 +687,20 @@ public class RealmEntity {
}
public Collection<AuthenticatorConfigEntity> getAuthenticatorConfigs() {
if (authenticators == null) {
authenticators = new LinkedList<>();
}
return authenticators;
}
public void setAuthenticatorConfigs(Collection<AuthenticatorConfigEntity> authenticators) {
this.authenticators = authenticators;
}
public Collection<RequiredActionProviderEntity> getRequiredActionProviders() {
if (requiredActionProviders == null) {
requiredActionProviders = new LinkedList<>();
}
return requiredActionProviders;
}
@ -666,6 +709,9 @@ public class RealmEntity {
}
public Collection<AuthenticationFlowEntity> getAuthenticationFlows() {
if (authenticationFlows == null) {
authenticationFlows = new LinkedList<>();
}
return authenticationFlows;
}
@ -674,6 +720,9 @@ public class RealmEntity {
}
public Set<ComponentEntity> getComponents() {
if (components == null) {
components = new HashSet<>();
}
return components;
}
@ -779,6 +828,9 @@ public class RealmEntity {
}
public Collection<ClientScopeEntity> getClientScopes() {
if (clientScopes == null) {
clientScopes = new LinkedList<>();
}
return clientScopes;
}

View file

@ -38,9 +38,9 @@ import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
@ -101,12 +101,12 @@ public class RoleEntity {
@ManyToMany(fetch = FetchType.LAZY, cascade = {})
@JoinTable(name = "COMPOSITE_ROLE", joinColumns = @JoinColumn(name = "COMPOSITE"), inverseJoinColumns = @JoinColumn(name = "CHILD_ROLE"))
private Set<RoleEntity> compositeRoles = new HashSet<>();
private Set<RoleEntity> compositeRoles;
@OneToMany(cascade = CascadeType.REMOVE, orphanRemoval = true, mappedBy="role")
@Fetch(FetchMode.SELECT)
@BatchSize(size = 20)
protected List<RoleAttributeEntity> attributes = new ArrayList<>();
protected Collection<RoleAttributeEntity> attributes;
public String getId() {
return id;
@ -125,10 +125,13 @@ public class RoleEntity {
}
public Collection<RoleAttributeEntity> getAttributes() {
if (attributes == null) {
attributes = new LinkedList<>();
}
return attributes;
}
public void setAttributes(List<RoleAttributeEntity> attributes) {
public void setAttributes(Collection<RoleAttributeEntity> attributes) {
this.attributes = attributes;
}
@ -149,6 +152,9 @@ public class RoleEntity {
}
public Set<RoleEntity> getCompositeRoles() {
if (compositeRoles == null) {
compositeRoles = new HashSet<>();
}
return compositeRoles;
}

View file

@ -31,8 +31,8 @@ import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
/**
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
@ -73,7 +73,7 @@ public class UserConsentEntity {
protected String externalClientId;
@OneToMany(cascade ={CascadeType.REMOVE}, orphanRemoval = true, mappedBy = "userConsent")
Collection<UserConsentClientScopeEntity> grantedClientScopes = new ArrayList<>();
Collection<UserConsentClientScopeEntity> grantedClientScopes;
@Column(name = "CREATED_DATE")
private Long createdDate;
@ -98,6 +98,9 @@ public class UserConsentEntity {
}
public Collection<UserConsentClientScopeEntity> getGrantedClientScopes() {
if (grantedClientScopes == null) {
grantedClientScopes = new LinkedList<>();
}
return grantedClientScopes;
}

View file

@ -34,8 +34,8 @@ import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
/**
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
@ -98,17 +98,17 @@ public class UserEntity {
@OneToMany(cascade = CascadeType.REMOVE, orphanRemoval = true, mappedBy="user")
@Fetch(FetchMode.SELECT)
@BatchSize(size = 20)
protected Collection<UserAttributeEntity> attributes = new ArrayList<UserAttributeEntity>();
protected Collection<UserAttributeEntity> attributes;
@OneToMany(cascade = CascadeType.REMOVE, orphanRemoval = true, mappedBy="user")
@Fetch(FetchMode.SELECT)
@BatchSize(size = 20)
protected Collection<UserRequiredActionEntity> requiredActions = new ArrayList<UserRequiredActionEntity>();
protected Collection<UserRequiredActionEntity> requiredActions;
@OneToMany(cascade = CascadeType.REMOVE, orphanRemoval = true, mappedBy="user")
@Fetch(FetchMode.SELECT)
@BatchSize(size = 20)
protected Collection<CredentialEntity> credentials = new ArrayList<CredentialEntity>();
protected Collection<CredentialEntity> credentials;
@Column(name="FEDERATION_LINK")
protected String federationLink;
@ -193,6 +193,9 @@ public class UserEntity {
}
public Collection<UserAttributeEntity> getAttributes() {
if (attributes == null) {
attributes = new LinkedList<>();
}
return attributes;
}
@ -201,6 +204,9 @@ public class UserEntity {
}
public Collection<UserRequiredActionEntity> getRequiredActions() {
if (requiredActions == null) {
requiredActions = new LinkedList<>();
}
return requiredActions;
}
@ -217,6 +223,9 @@ public class UserEntity {
}
public Collection<CredentialEntity> getCredentials() {
if (credentials == null) {
credentials = new LinkedList<>();
}
return credentials;
}