Skip to content

Commit

Permalink
Merge pull request #3415 from ebean-orm/feature/3412
Browse files Browse the repository at this point in the history
#3412 Use existing/parent transaction with fetch query on ToMany paths
  • Loading branch information
rbygrave committed Jun 7, 2024
2 parents d817dcb + 3c84a90 commit 7b2128b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,17 @@ private List<Object> ids() {
return idList;
}

public SpiQuery<?> createQuery(SpiEbeanServer server) {
final SpiQuery<?> query = server.createQuery(beanType());
query.usingTransaction(transaction);
configureQuery(query);
return query;
}

/**
* Configure the query for lazy loading execution.
*/
public void configureQuery(SpiQuery<?> query) {
private void configureQuery(SpiQuery<?> query) {
query.setMode(Mode.LAZYLOAD_BEAN);
query.setPersistenceContext(loadBuffer.persistenceContext());
query.setLoadDescription(mode(), description());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ private BeanPropertyAssocMany<?> many() {
public SpiQuery<?> createQuery(SpiEbeanServer server) {
BeanPropertyAssocMany<?> many = many();
SpiQuery<?> query = many.newQuery(server);
query.usingTransaction(transaction);
String orderBy = many.lazyFetchOrderBy();
if (orderBy != null) {
query.orderBy(orderBy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@ void loadBean(LoadBeanRequest loadRequest) {
if (loadRequest.checkEmpty()) {
throw new RuntimeException("Nothing in batch?");
}
final SpiQuery<?> query = server.createQuery(loadRequest.beanType());
query.usingTransaction(loadRequest.transaction());
loadRequest.configureQuery(query);
final SpiQuery<?> query = loadRequest.createQuery(server);
loadRequest.postLoad(executeQuery(loadRequest, query));
}

Expand Down

0 comments on commit 7b2128b

Please sign in to comment.