mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1933 - ENH: Add DtoQuery.usingTransaction(Transaction) ... dto query with supplied transaction
This commit is contained in:
@@ -136,4 +136,8 @@ public interface DtoQuery<T> {
|
||||
*/
|
||||
DtoQuery<T> setBufferFetchSizeHint(int bufferFetchSizeHint);
|
||||
|
||||
/**
|
||||
* Use the explicit transaction to execute the query.
|
||||
*/
|
||||
DtoQuery<T> usingTransaction(Transaction transaction);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.ebeaninternal.api;
|
||||
|
||||
import io.ebean.DtoQuery;
|
||||
import io.ebean.ProfileLocation;
|
||||
import io.ebean.Transaction;
|
||||
import io.ebeaninternal.server.dto.DtoMappingRequest;
|
||||
import io.ebeaninternal.server.dto.DtoQueryPlan;
|
||||
|
||||
@@ -65,4 +66,9 @@ public interface SpiDtoQuery<T> extends DtoQuery<T>, SpiSqlBinding {
|
||||
*/
|
||||
SpiQuery<?> getOrmQuery();
|
||||
|
||||
/**
|
||||
* Return the explicit transaction used to execute the query.
|
||||
*/
|
||||
Transaction getTransaction();
|
||||
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public final class DtoQueryRequest<T> extends AbstractSqlQueryRequest {
|
||||
private DataReader dataReader;
|
||||
|
||||
DtoQueryRequest(SpiEbeanServer server, DtoQueryEngine engine, SpiDtoQuery<T> query) {
|
||||
super(server, query, null);
|
||||
super(server, query, query.getTransaction());
|
||||
this.queryEngine = engine;
|
||||
this.query = query;
|
||||
query.obtainLocation();
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.ebeaninternal.server.querydefn;
|
||||
|
||||
import io.ebean.DtoQuery;
|
||||
import io.ebean.ProfileLocation;
|
||||
import io.ebean.Transaction;
|
||||
import io.ebeaninternal.api.BindParams;
|
||||
import io.ebeaninternal.api.SpiDtoQuery;
|
||||
import io.ebeaninternal.api.SpiEbeanServer;
|
||||
@@ -47,6 +48,8 @@ public class DefaultDtoQuery<T> implements SpiDtoQuery<T> {
|
||||
*/
|
||||
private final BindParams bindParams = new BindParams();
|
||||
|
||||
private Transaction transaction;
|
||||
|
||||
/**
|
||||
* Create given an underlying ORM query.
|
||||
*/
|
||||
@@ -88,6 +91,12 @@ public class DefaultDtoQuery<T> implements SpiDtoQuery<T> {
|
||||
descriptor.putQueryPlan(planKey, plan);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DtoQuery<T> usingTransaction(Transaction transaction) {
|
||||
this.transaction = transaction;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void findEach(Consumer<T> consumer) {
|
||||
server.findDtoEach(this, consumer);
|
||||
@@ -148,6 +157,11 @@ public class DefaultDtoQuery<T> implements SpiDtoQuery<T> {
|
||||
return ormQuery;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction getTransaction() {
|
||||
return transaction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DtoQuery<T> setRelaxedMode() {
|
||||
this.relaxedMode = true;
|
||||
|
||||
Reference in New Issue
Block a user