Class AsyncEntityQuery<E extends BaseEntity>
java.lang.Object
com.github.collinalpert.java2db.queries.EntityQuery<E>
com.github.collinalpert.java2db.queries.async.AsyncEntityQuery<E>
- All Implemented Interfaces:
AsyncQueryable<E>,Queryable<E>
public class AsyncEntityQuery<E extends BaseEntity> extends EntityQuery<E> implements AsyncQueryable<E>
- Author:
- Collin Alpert
-
Field Summary
Fields inherited from class com.github.collinalpert.java2db.queries.EntityQuery
connectionConfiguration, queryBuilder, queryParameters -
Constructor Summary
Constructors Constructor Description AsyncEntityQuery(Class<E> type, ConnectionConfiguration connectionConfiguration)Constructor for creating a DQL statement for a given entity. -
Method Summary
Modifier and Type Method Description AsyncEntityQuery<E>limit(int limit)Limits the result of the rows returned to a maximum of the passed integer.AsyncEntityQuery<E>limit(int limit, int offset)Limits the result of the rows returned to a maximum of the passed integer with an offset.AsyncEntityQuery<E>orderBy(com.github.collinalpert.lambda2sql.functions.SqlFunction<E,?> function)Sets an ORDER BY clauses for the DQL statement.AsyncEntityQuery<E>orderBy(com.github.collinalpert.lambda2sql.functions.SqlFunction<E,?>[] functions)Sets multiple ORDER BY clauses for the DQL statement.AsyncEntityQuery<E>orderBy(com.github.collinalpert.lambda2sql.functions.SqlFunction<E,?>[] functions, OrderTypes orderType)Sets multiple ORDER BY clauses for the DQL statement with a sorting order option.AsyncEntityQuery<E>orderBy(com.github.collinalpert.lambda2sql.functions.SqlFunction<E,?> function, OrderTypes orderType)Sets an ORDER BY clauses for the DQL statement with a sorting order option.AsyncEntityQuery<E>orderBy(List<com.github.collinalpert.lambda2sql.functions.SqlFunction<E,?>> functions)Sets multiple ORDER BY clauses for the DQL statement.AsyncEntityQuery<E>orderBy(List<com.github.collinalpert.lambda2sql.functions.SqlFunction<E,?>> functions, OrderTypes orderType)Sets multiple ORDER BY clauses for the DQL statement with a sorting order option.AsyncEntityQuery<E>orWhere(com.github.collinalpert.lambda2sql.functions.SqlPredicate<E> predicate)Sets or appends an OR WHERE clause to the DQL statement.<R> AsyncQueryable<R>project(com.github.collinalpert.lambda2sql.functions.SqlFunction<E,R> projection)Selects only a single column from a table.AsyncEntityQuery<E>where(com.github.collinalpert.lambda2sql.functions.SqlPredicate<E> predicate)Sets or appends a WHERE clause for the DQL statement.Methods inherited from class com.github.collinalpert.java2db.queries.EntityQuery
distinct, first, getQuery, getTableName, groupBy, groupBy, thenBy, thenBy, thenBy, thenBy, thenBy, thenBy, toArray, toList, toMap, toSet, toStreamMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.github.collinalpert.java2db.queries.async.AsyncQueryable
firstAsync, firstAsync, toArrayAsync, toArrayAsync, toListAsync, toListAsync, toMapAsync, toMapAsync, toMapAsync, toMapAsync, toSetAsync, toSetAsync, toStreamAsync, toStreamAsync
-
Constructor Details
-
AsyncEntityQuery
Constructor for creating a DQL statement for a given entity. This constructor should not be used directly, but through the DQL methods defined in theBaseService.- Parameters:
type- The entity to query.
-
-
Method Details
-
where
public AsyncEntityQuery<E> where(com.github.collinalpert.lambda2sql.functions.SqlPredicate<E> predicate)Sets or appends a WHERE clause for the DQL statement.- Overrides:
wherein classEntityQuery<E extends BaseEntity>- Parameters:
predicate- The predicate describing the WHERE clause.- Returns:
- This
EntityQueryobject, now with an (appended) WHERE clause.
-
orWhere
public AsyncEntityQuery<E> orWhere(com.github.collinalpert.lambda2sql.functions.SqlPredicate<E> predicate)Sets or appends an OR WHERE clause to the DQL statement.- Overrides:
orWherein classEntityQuery<E extends BaseEntity>- Parameters:
predicate- The predicate describing the OR WHERE clause.- Returns:
- This
EntityQueryobject, now with an (appended) OR WHERE clause.
-
orderBy
public AsyncEntityQuery<E> orderBy(com.github.collinalpert.lambda2sql.functions.SqlFunction<E,?> function)Sets an ORDER BY clauses for the DQL statement.- Overrides:
orderByin classEntityQuery<E extends BaseEntity>- Parameters:
function- The column to order by.- Returns:
- This
EntityQueryobject, now with a ORDER BY clause.
-
orderBy
public AsyncEntityQuery<E> orderBy(com.github.collinalpert.lambda2sql.functions.SqlFunction<E,?>[] functions)Sets multiple ORDER BY clauses for the DQL statement. The resulting ORDER BY statement will coalesce the passed columns.- Overrides:
orderByin classEntityQuery<E extends BaseEntity>- Parameters:
functions- The columns to order by in a coalescing manner.- Returns:
- This
EntityQueryobject, now with a coalesced ORDER BY clause.
-
orderBy
public AsyncEntityQuery<E> orderBy(List<com.github.collinalpert.lambda2sql.functions.SqlFunction<E,?>> functions)Sets multiple ORDER BY clauses for the DQL statement. The resulting ORDER BY statement will coalesce the passed columns.- Overrides:
orderByin classEntityQuery<E extends BaseEntity>- Parameters:
functions- The columns to order by in a coalescing manner.- Returns:
- This
EntityQueryobject, now with a coalesced ORDER BY clause.
-
orderBy
public AsyncEntityQuery<E> orderBy(com.github.collinalpert.lambda2sql.functions.SqlFunction<E,?> function, OrderTypes orderType)Sets an ORDER BY clauses for the DQL statement with a sorting order option.- Overrides:
orderByin classEntityQuery<E extends BaseEntity>- Parameters:
function- The column to order by.orderType- The direction to order by. Can be either ascending or descending.- Returns:
- This
EntityQueryobject, now with a ORDER BY clause.
-
orderBy
public AsyncEntityQuery<E> orderBy(com.github.collinalpert.lambda2sql.functions.SqlFunction<E,?>[] functions, OrderTypes orderType)Sets multiple ORDER BY clauses for the DQL statement with a sorting order option. The resulting ORDER BY statement will coalesce the passed columns.- Overrides:
orderByin classEntityQuery<E extends BaseEntity>- Parameters:
orderType- The direction to order by. Can be either ascending or descending.functions- The columns to order by in a coalescing manner.- Returns:
- This
EntityQueryobject, now with a coalesced ORDER BY clause.
-
orderBy
public AsyncEntityQuery<E> orderBy(List<com.github.collinalpert.lambda2sql.functions.SqlFunction<E,?>> functions, OrderTypes orderType)Sets multiple ORDER BY clauses for the DQL statement with a sorting order option. The resulting ORDER BY statement will coalesce the passed columns.- Overrides:
orderByin classEntityQuery<E extends BaseEntity>- Parameters:
orderType- The direction to order by. Can be either ascending or descending.functions- The columns to order by in a coalescing manner.- Returns:
- This
EntityQueryobject, now with a coalesced ORDER BY clause.
-
limit
Limits the result of the rows returned to a maximum of the passed integer with an offset. For example, the call.limit(10, 5)would return the rows 6-15.- Overrides:
limitin classEntityQuery<E extends BaseEntity>- Parameters:
limit- The maximum of rows to be returned.offset- The offset of the limit.- Returns:
- This
EntityQueryobject, now with a LIMIT with an OFFSET.
-
limit
Limits the result of the rows returned to a maximum of the passed integer.- Overrides:
limitin classEntityQuery<E extends BaseEntity>- Parameters:
limit- The maximum of rows to be returned.- Returns:
- This
EntityQueryobject, now with a LIMIT.
-
project
public <R> AsyncQueryable<R> project(com.github.collinalpert.lambda2sql.functions.SqlFunction<E,R> projection)Selects only a single column from a table. This is meant if you don't want to fetch an entire entity from the database.- Overrides:
projectin classEntityQuery<E extends BaseEntity>- Type Parameters:
R- The type of the column you want to retrieve.- Parameters:
projection- The column to project to.- Returns:
- A queryable containing the projection.
-