KEYCLOAK-16034 Not scroll-able event queries for postgres and mssql
This commit is contained in:
parent
925f089d62
commit
b494b8bb44
2 changed files with 11 additions and 3 deletions
|
@ -35,6 +35,7 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.keycloak.events.jpa.JpaEventQuery.DEFAULT_MAX_RESULTS;
|
||||
import static org.keycloak.utils.StreamsUtil.closing;
|
||||
|
||||
/**
|
||||
|
@ -158,9 +159,12 @@ public class JpaAdminEventQuery implements AdminEventQuery {
|
|||
|
||||
if (maxResults != null) {
|
||||
query.setMaxResults(maxResults);
|
||||
} else {
|
||||
// to workaround https://hibernate.atlassian.net/browse/HHH-14295
|
||||
query.setMaxResults(DEFAULT_MAX_RESULTS);
|
||||
}
|
||||
|
||||
return closing(query.getResultList().stream().map(JpaEventStoreProvider::convertAdminEvent));
|
||||
return closing(query.getResultStream().map(JpaEventStoreProvider::convertAdminEvent));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -48,6 +48,8 @@ public class JpaEventQuery implements EventQuery {
|
|||
private Integer firstResult;
|
||||
private Integer maxResults;
|
||||
|
||||
public static final int DEFAULT_MAX_RESULTS = Integer.MAX_VALUE >> 1;
|
||||
|
||||
public JpaEventQuery(EntityManager em) {
|
||||
this.em = em;
|
||||
|
||||
|
@ -131,10 +133,12 @@ public class JpaEventQuery implements EventQuery {
|
|||
|
||||
if (maxResults != null) {
|
||||
query.setMaxResults(maxResults);
|
||||
} else {
|
||||
// to workaround https://hibernate.atlassian.net/browse/HHH-14295
|
||||
query.setMaxResults(DEFAULT_MAX_RESULTS);
|
||||
}
|
||||
|
||||
|
||||
return closing(query.getResultList().stream().map(JpaEventStoreProvider::convertEvent));
|
||||
return closing(query.getResultStream().map(JpaEventStoreProvider::convertEvent));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue