mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-10-24 08:25:50 +00:00
#799 - Query.fetch(path) when converted to query join default to batchSize 10 rather than 100
This commit is contained in:
@@ -56,11 +56,9 @@ public abstract class DLoadBaseContext {
|
||||
|
||||
int queryBatchSize = queryProps.getQueryFetchBatch();
|
||||
if (queryBatchSize == -1) {
|
||||
// not eager query fetch, just lazy loading
|
||||
return batchSize;
|
||||
|
||||
} else if (queryBatchSize == 0) {
|
||||
// default query fetch batch size is 100
|
||||
return 100;
|
||||
|
||||
} else {
|
||||
|
||||
@@ -284,20 +284,23 @@ public class DLoadContext implements LoadContext {
|
||||
|
||||
private void registerSecondaryNode(boolean many, OrmQueryProperties props) {
|
||||
|
||||
String path = props.getPath();
|
||||
int lazyJoinBatch = props.getLazyFetchBatch();
|
||||
int batchSize = lazyJoinBatch > 0 ? lazyJoinBatch : defaultBatchSize;
|
||||
|
||||
if (many) {
|
||||
DLoadManyContext manyContext = createManyContext(path, batchSize, props);
|
||||
manyMap.put(path, manyContext);
|
||||
int batchSize;
|
||||
if (props.isQueryFetch()) {
|
||||
batchSize = 100;
|
||||
} else {
|
||||
DLoadBeanContext beanContext = createBeanContext(path, batchSize, props);
|
||||
beanMap.put(path, beanContext);
|
||||
int lazyJoinBatch = props.getLazyFetchBatch();
|
||||
batchSize = lazyJoinBatch > 0 ? lazyJoinBatch : defaultBatchSize;
|
||||
}
|
||||
|
||||
String path = props.getPath();
|
||||
if (many) {
|
||||
manyMap.put(path, createManyContext(path, batchSize, props));
|
||||
} else {
|
||||
beanMap.put(path, createBeanContext(path, batchSize, props));
|
||||
}
|
||||
}
|
||||
|
||||
private DLoadManyContext getManyContext(String path) {
|
||||
protected DLoadManyContext getManyContext(String path) {
|
||||
if (path == null) {
|
||||
throw new RuntimeException("path is null?");
|
||||
}
|
||||
|
||||
@@ -77,4 +77,19 @@ public class DLoadContextTest extends BaseTestCase {
|
||||
assertThat(customer.secondaryBatchSize).isEqualTo(5);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void construct_when_fetch_expect_100_100_batchSize() {
|
||||
|
||||
// the fetch is converted to a query join due to the maxRows
|
||||
OrmQueryRequest<Order> queryRequest = queryRequest(query().fetch("details").setMaxRows(100)) ;
|
||||
queryRequest.initTransIfRequired();
|
||||
queryRequest.endTransIfRequired();
|
||||
|
||||
DLoadContext graphContext = (DLoadContext)queryRequest.getGraphContext();
|
||||
DLoadManyContext details = graphContext.getManyContext("details");
|
||||
|
||||
assertThat(details.firstBatchSize).isEqualTo(100);
|
||||
assertThat(details.secondaryBatchSize).isEqualTo(100);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user