mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-19 23:02:24 +00:00
Remove deprecated findLargeStream(), migrate to findStream()
findLargeStream() became no longer become needed due to improvements in the persistence context. Migrate to just use findStream() instead.
This commit is contained in:
1 parent
a87897dd46
commit
48d7e79b16
9 files changed
-103
No files matched your search
@@ -112,19 +112,6 @@ public interface ExtendedServer {
|
|||||||
*/
|
*/
|
||||||
<T> Stream<T> findStream(Query<T> query, Transaction transaction);
|
<T> Stream<T> findStream(Query<T> query, Transaction transaction);
|
||||||
|
|
||||||
/**
|
|
||||||
* Deprecated - migrate to findStream().
|
|
||||||
* <p>
|
|
||||||
* Execute the query returning the result as a Stream.
|
|
||||||
* <p>
|
|
||||||
* Note that this can support very large queries iterating any number of results.
|
|
||||||
* To do so internally it can use multiple persistence contexts.
|
|
||||||
* <p>
|
|
||||||
* Note that the stream needs to be closed so use with try with resources.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
<T> Stream<T> findLargeStream(Query<T> query, Transaction transaction);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the query visiting the each bean one at a time.
|
* Execute the query visiting the each bean one at a time.
|
||||||
* <p>
|
* <p>
|
||||||
|
|||||||
@@ -750,29 +750,6 @@ public interface Query<T> extends CancelableQuery {
|
|||||||
*/
|
*/
|
||||||
Stream<T> findStream();
|
Stream<T> findStream();
|
||||||
|
|
||||||
/**
|
|
||||||
* Deprecated - migrate to findStream.
|
|
||||||
* <p>
|
|
||||||
* Execute the query returning the result as a Stream.
|
|
||||||
* <p>
|
|
||||||
* Note that this uses multiple persistence contexts such that we can use
|
|
||||||
* it with a large number of results.
|
|
||||||
* </p>
|
|
||||||
* <pre>{@code
|
|
||||||
*
|
|
||||||
* // use try with resources to ensure Stream is closed
|
|
||||||
*
|
|
||||||
* try (Stream<Customer> stream = query.findLargeStream()) {
|
|
||||||
* stream
|
|
||||||
* .map(...)
|
|
||||||
* .collect(...);
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* }</pre>
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
Stream<T> findLargeStream();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the query processing the beans one at a time.
|
* Execute the query processing the beans one at a time.
|
||||||
* <p>
|
* <p>
|
||||||
|
|||||||
@@ -1376,11 +1376,6 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T> Stream<T> findLargeStream(Query<T> query, Transaction transaction) {
|
|
||||||
return findStream(query, transaction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> Stream<T> findStream(Query<T> query, Transaction transaction) {
|
public <T> Stream<T> findStream(Query<T> query, Transaction transaction) {
|
||||||
return toStream(findIterate(query, transaction));
|
return toStream(findIterate(query, transaction));
|
||||||
|
|||||||
@@ -251,11 +251,6 @@ final class DefaultFetchGroupQuery<T> implements SpiFetchGroupQuery<T>, SpiQuery
|
|||||||
throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
|
throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Stream<T> findLargeStream() {
|
|
||||||
throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void findEach(Consumer<T> consumer) {
|
public void findEach(Consumer<T> consumer) {
|
||||||
throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
|
throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
|
||||||
|
|||||||
@@ -1456,11 +1456,6 @@ public final class DefaultOrmQuery<T> extends AbstractQuery implements SpiQuery<
|
|||||||
return server.findStream(this, transaction);
|
return server.findStream(this, transaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Stream<T> findLargeStream() {
|
|
||||||
return server.findLargeStream(this, transaction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Version<T>> findVersions() {
|
public List<Version<T>> findVersions() {
|
||||||
this.temporalMode = TemporalMode.VERSIONS;
|
this.temporalMode = TemporalMode.VERSIONS;
|
||||||
|
|||||||
@@ -1646,14 +1646,6 @@ public abstract class TQRootBean<T, R> {
|
|||||||
return query.findStream();
|
return query.findStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Deprecated - migrate to findStream().
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public Stream<T> findLargeStream() {
|
|
||||||
return query.findLargeStream();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the query returning the set of objects.
|
* Execute the query returning the set of objects.
|
||||||
* <p>
|
* <p>
|
||||||
|
|||||||
@@ -387,24 +387,6 @@ public class QCustomerTest {
|
|||||||
assertThat(sb.toString()).isEqualTo("stream1|stream2");
|
assertThat(sb.toString()).isEqualTo("stream1|stream2");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFindLargeStream() {
|
|
||||||
insertCustomer("largeStream1");
|
|
||||||
insertCustomer("largeStream2");
|
|
||||||
insertCustomer("largeStream3");
|
|
||||||
|
|
||||||
StringJoiner sb = new StringJoiner("|");
|
|
||||||
try (Stream<Customer> stream = new QCustomer()
|
|
||||||
.name.startsWith("largeStream")
|
|
||||||
.id.asc()
|
|
||||||
.findLargeStream()) {
|
|
||||||
|
|
||||||
stream.forEach(it -> sb.add(it.getName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
assertThat(sb.toString()).isEqualTo("largeStream1|largeStream2|largeStream3");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFilterMany() {
|
public void testFilterMany() {
|
||||||
|
|
||||||
|
|||||||
@@ -653,11 +653,6 @@ public class TDSpiEbeanServer extends TDSpiServer implements SpiEbeanServer {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T> Stream<T> findLargeStream(Query<T> query, Transaction transaction) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> void findEach(Query<T> query, Consumer<T> consumer, Transaction transaction) {
|
public <T> void findEach(Query<T> query, Consumer<T> consumer, Transaction transaction) {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,27 +37,6 @@ public class TestQueryFindStream extends BaseTestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void findLargeStream_basic() {
|
|
||||||
ResetBasicData.reset();
|
|
||||||
try (Stream<Customer> stream = DB.find(Customer.class)
|
|
||||||
.findLargeStream()) {
|
|
||||||
|
|
||||||
// bad example, don't use a stream like this when we can
|
|
||||||
// use findSingleAttributeList() instead
|
|
||||||
final List<String> namesStream = stream
|
|
||||||
.map(Customer::getName)
|
|
||||||
.collect(toList());
|
|
||||||
|
|
||||||
final List<String> namesQuery = DB.find(Customer.class)
|
|
||||||
.select("name")
|
|
||||||
.findSingleAttributeList();
|
|
||||||
|
|
||||||
assertThat(namesStream).hasSize(namesQuery.size());
|
|
||||||
assertThat(namesStream).containsAll(namesQuery);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void manualTest_findSteam_when_closeWithResources() {
|
public void manualTest_findSteam_when_closeWithResources() {
|
||||||
// confirm manually the stream is closed via try with resources block
|
// confirm manually the stream is closed via try with resources block
|
||||||
|
|||||||
Reference in new issue
Block a user