changed user and resource entity to fetch mode select with batch size 20

This commit is contained in:
Leon Graser 2018-09-06 11:23:32 +02:00 committed by Hynek Mlnařík
parent 0561d73ae2
commit df22c4d613
2 changed files with 10 additions and 4 deletions

View file

@ -44,6 +44,7 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Fetch; import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.FetchMode;
@ -109,7 +110,8 @@ public class ResourceEntity {
private List<PolicyEntity> policies = new LinkedList<>(); private List<PolicyEntity> policies = new LinkedList<>();
@OneToMany(cascade = CascadeType.REMOVE, orphanRemoval = true, mappedBy="resource") @OneToMany(cascade = CascadeType.REMOVE, orphanRemoval = true, mappedBy="resource")
@Fetch(FetchMode.SUBSELECT) @Fetch(FetchMode.SELECT)
@BatchSize(size = 20)
private Collection<ResourceAttributeEntity> attributes = new ArrayList<>(); private Collection<ResourceAttributeEntity> attributes = new ArrayList<>();
public String getId() { public String getId() {

View file

@ -17,6 +17,7 @@
package org.keycloak.models.jpa.entities; package org.keycloak.models.jpa.entities;
import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Fetch; import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.Nationalized; import org.hibernate.annotations.Nationalized;
@ -96,15 +97,18 @@ public class UserEntity {
protected String realmId; protected String realmId;
@OneToMany(cascade = CascadeType.REMOVE, orphanRemoval = true, mappedBy="user") @OneToMany(cascade = CascadeType.REMOVE, orphanRemoval = true, mappedBy="user")
@Fetch(FetchMode.SUBSELECT) @Fetch(FetchMode.SELECT)
@BatchSize(size = 20)
protected Collection<UserAttributeEntity> attributes = new ArrayList<UserAttributeEntity>(); protected Collection<UserAttributeEntity> attributes = new ArrayList<UserAttributeEntity>();
@OneToMany(cascade = CascadeType.REMOVE, orphanRemoval = true, mappedBy="user") @OneToMany(cascade = CascadeType.REMOVE, orphanRemoval = true, mappedBy="user")
@Fetch(FetchMode.SUBSELECT) @Fetch(FetchMode.SELECT)
@BatchSize(size = 20)
protected Collection<UserRequiredActionEntity> requiredActions = new ArrayList<UserRequiredActionEntity>(); protected Collection<UserRequiredActionEntity> requiredActions = new ArrayList<UserRequiredActionEntity>();
@OneToMany(cascade = CascadeType.REMOVE, orphanRemoval = true, mappedBy="user") @OneToMany(cascade = CascadeType.REMOVE, orphanRemoval = true, mappedBy="user")
@Fetch(FetchMode.SUBSELECT) @Fetch(FetchMode.SELECT)
@BatchSize(size = 20)
protected Collection<CredentialEntity> credentials = new ArrayList<CredentialEntity>(); protected Collection<CredentialEntity> credentials = new ArrayList<CredentialEntity>();
@Column(name="FEDERATION_LINK") @Column(name="FEDERATION_LINK")