Skip to content

Commit c4230c7

Browse files
authored
Add usingMaster() to SqlQuery.TypeQuery (#3744)
1 parent 794f933 commit c4230c7

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

ebean-api/src/main/java/io/ebean/SqlQuery.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,14 @@ default SqlQuery usingMaster() {
367367
*/
368368
interface TypeQuery<T> {
369369

370+
/**
371+
* Ensure the master DataSource is used when useMaster is true. Otherwise, the read only
372+
* data source can be used if defined.
373+
*
374+
* @see SqlQuery#usingMaster(boolean)
375+
*/
376+
TypeQuery<T> usingMaster(boolean useMaster);
377+
370378
/**
371379
* Execute the query using the given transaction.
372380
*/

ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultRelationalQuery.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,12 @@ private class Scalar<T> implements SqlQuery.TypeQuery<T> {
269269
this.type = type;
270270
}
271271

272+
@Override
273+
public TypeQuery<T> usingMaster(boolean useMaster) {
274+
DefaultRelationalQuery.this.usingMaster(useMaster);
275+
return this;
276+
}
277+
272278
@Override
273279
public TypeQuery<T> usingTransaction(Transaction transaction) {
274280
transaction(transaction);
@@ -308,6 +314,12 @@ private class Mapper<T> implements SqlQuery.TypeQuery<T> {
308314
this.mapper = mapper;
309315
}
310316

317+
@Override
318+
public TypeQuery<T> usingMaster(boolean useMaster) {
319+
DefaultRelationalQuery.this.usingMaster(useMaster);
320+
return this;
321+
}
322+
311323
@Override
312324
public TypeQuery<T> usingTransaction(Transaction transaction) {
313325
transaction(transaction);

0 commit comments

Comments
 (0)