- Type Parameters:
T- the type of the table being queried.ID- the type of the primary key.
- All Implemented Interfaces:
Subqueryable
DeleteBuilderImpl relies on preview features of the Java platform:
DeleteBuilderImplrefers to one or more preview APIs:StringTemplate.
-
Nested Class Summary
Nested classes/interfaces inherited from class st.orm.template.QueryBuilder
QueryBuilder.JoinBuilder<T extends Record,R, ID>, QueryBuilder.PredicateBuilder<T extends Record, R, ID>, QueryBuilder.TypedJoinBuilder<T extends Record, R, ID>, QueryBuilder.WhereBuilder<T extends Record, R, ID> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final List<st.orm.template.impl.Join> protected final QueryTemplateprotected final List<StringTemplatePREVIEW> protected final List<Elements.Where> -
Constructor Summary
ConstructorsConstructorDescriptionDeleteBuilderImpl(QueryTemplate queryTemplate, Class<T> fromType, Supplier<Model<T, ID>> modelSupplier) -
Method Summary
Modifier and TypeMethodDescriptionappend(StringTemplatePREVIEW template) Append the query with a string template.build()Builds the query based on the current state of the query builder.Adds a cross join to the query.crossJoin(StringTemplatePREVIEW template) Adds a cross join to the query.distinct()Marks the current query as a distinct query.forLock(StringTemplatePREVIEW template) Locks the selected rows using a custom lock mode.forShare()Locks the selected rows for reading.Locks the selected rows for reading.Executes the query and returns a stream of results.Returns the template for the query for the subquery.Adds an inner join to the query.innerJoin(StringTemplatePREVIEW template, String alias) Adds an inner join to the query.Adds a join of the specified type to the query.join(JoinType type, StringTemplatePREVIEW template, String alias) Adds a join of the specified type to the query using a template.join(JoinType type, QueryBuilder<?, ?, ?> subquery, String alias) Adds a join of the specified type to the query using a subquery.Adds a left join to the query.leftJoin(StringTemplatePREVIEW template, String alias) Adds a left join to the query.limit(int limit) Adds a LIMIT clause to the query.offset(int offset) Adds an OFFSET clause to the query.Adds a right join to the query.rightJoin(StringTemplatePREVIEW template, String alias) Adds a right join to the query.safe()Returns a query builder that does not require a WHERE clause for UPDATE and DELETE queries.protected booleanIndicates whether the DELETE query supports joins.<X> QueryBuilder<T, Object, X> Returns a typed query builder for the specified primary key type.where(Function<QueryBuilder.WhereBuilder<T, Object, ID>, QueryBuilder.PredicateBuilder<?, ?, ?>> predicate) Adds a WHERE clause to the query using aQueryBuilder.WhereBuilder.Methods inherited from class st.orm.template.QueryBuilder
executeUpdate, getOptionalResult, getResult, getResultCount, getResultList, getSingleResult, groupBy, groupBy, groupBy, groupByAny, having, having, havingAny, orderBy, orderBy, orderBy, orderByAny, orderByDescending, prepare, slice, slice, where, where, where, where, where, where, where, where, where, where, whereId, whereRef, whereRef
-
Field Details
-
queryTemplate
-
fromType
-
join
-
where
-
templates
-
modelSupplier
-
-
Constructor Details
-
DeleteBuilderImpl
-
-
Method Details
-
safe
Returns a query builder that does not require a WHERE clause for UPDATE and DELETE queries.This method is used to prevent accidental updates or deletions of all records in a table when a WHERE clause is not provided.
-
supportsJoin
protected boolean supportsJoin()Indicates whether the DELETE query supports joins.- Returns:
- true if the query supports joins, false otherwise.
-
distinct
Marks the current query as a distinct query. -
offset
Adds an OFFSET clause to the query. -
limit
Adds a LIMIT clause to the query. -
forUpdate
Locks the selected rows for reading.- Specified by:
forUpdatein classQueryBuilder<T extends Record,Object, ID> - Returns:
- the query builder.
- Throws:
PersistenceException- if the database does not support the specified lock mode, or if the lock mode is not supported for the current query.
-
forLock
Locks the selected rows using a custom lock mode.Note that this method results in non-portable code, as the lock mode is specific to the underlying database.
- Specified by:
forLockin classQueryBuilder<T extends Record,Object, ID> - Returns:
- the query builder.
- Throws:
PersistenceException- if the lock mode is not supported for the current query.
-
getSubquery
Description copied from interface:SubqueryableReturns the template for the query for the subquery.- Returns:
- the template.
-
build
Builds the query based on the current state of the query builder. -
getResultStream
Executes the query and returns a stream of results.The resulting stream is lazily loaded, meaning that the records are only retrieved from the database as they are consumed by the stream. This approach is efficient and minimizes the memory footprint, especially when dealing with large volumes of records.
Note that calling this method does trigger the execution of the underlying query, so it should only be invoked when the query is intended to run. Since the stream holds resources open while in use, it must be closed after usage to prevent resource leaks. As the stream is AutoCloseable, it is recommended to use it within a try-with-resources block.
- Specified by:
getResultStreamin classQueryBuilder<T extends Record,Object, ID> - Returns:
- a stream of results.
- Throws:
PersistenceException- if the query operation fails due to underlying database issues, such as connectivity.
-
typed
Returns a typed query builder for the specified primary key type.- Specified by:
typedin classQueryBuilder<T extends Record,R, ID> - Type Parameters:
X- the type of the primary key.- Parameters:
pkType- the primary key type.- Returns:
- the typed query builder.
- Throws:
PersistenceException- if the pk type is not valid.- Since:
- 1.2
-
append
Append the query with a string template.- Specified by:
appendin classQueryBuilder<T extends Record,R, ID> - Parameters:
template- the string template to append.- Returns:
- the query builder.
-
crossJoin
Adds a cross join to the query.- Specified by:
crossJoinin classQueryBuilder<T extends Record,R, ID> - Parameters:
relation- the relation to join.- Returns:
- the query builder.
-
innerJoin
public QueryBuilder.TypedJoinBuilder<T,Object, innerJoinID> (@Nonnull Class<? extends Record> relation) Adds an inner join to the query.- Specified by:
innerJoinin classQueryBuilder<T extends Record,R, ID> - Parameters:
relation- the relation to join.- Returns:
- the query builder.
-
leftJoin
public QueryBuilder.TypedJoinBuilder<T,Object, leftJoinID> (@Nonnull Class<? extends Record> relation) Adds a left join to the query.- Specified by:
leftJoinin classQueryBuilder<T extends Record,R, ID> - Parameters:
relation- the relation to join.- Returns:
- the query builder.
-
rightJoin
public QueryBuilder.TypedJoinBuilder<T,Object, rightJoinID> (@Nonnull Class<? extends Record> relation) Adds a right join to the query.- Specified by:
rightJoinin classQueryBuilder<T extends Record,R, ID> - Parameters:
relation- the relation to join.- Returns:
- the query builder.
-
join
public QueryBuilder.JoinBuilder<T,Object, joinID> (@Nonnull JoinType type, @Nonnull StringTemplatePREVIEW template, @Nonnull String alias) Adds a join of the specified type to the query using a template.- Specified by:
joinin classQueryBuilder<T extends Record,R, ID> - Parameters:
type- the join type.template- the template to join.alias- the alias to use for the joined relation.- Returns:
- the query builder.
-
join
public QueryBuilder.JoinBuilder<T,Object, joinID> (@Nonnull JoinType type, @Nonnull QueryBuilder<?, ?, ?> subquery, @Nonnull String alias) Adds a join of the specified type to the query using a subquery.- Specified by:
joinin classQueryBuilder<T extends Record,R, ID> - Parameters:
type- the join type.subquery- the subquery to join.alias- the alias to use for the joined relation.- Returns:
- the query builder.
-
crossJoin
Adds a cross join to the query.- Specified by:
crossJoinin classQueryBuilder<T extends Record,R, ID> - Parameters:
template- the template to join.- Returns:
- the query builder.
-
innerJoin
public QueryBuilder.JoinBuilder<T,Object, innerJoinID> (@Nonnull StringTemplatePREVIEW template, @Nonnull String alias) Adds an inner join to the query.- Specified by:
innerJoinin classQueryBuilder<T extends Record,R, ID> - Parameters:
template- the template to join.alias- the alias to use for the joined relation.- Returns:
- the query builder.
-
leftJoin
public QueryBuilder.JoinBuilder<T,Object, leftJoinID> (@Nonnull StringTemplatePREVIEW template, @Nonnull String alias) Adds a left join to the query.- Specified by:
leftJoinin classQueryBuilder<T extends Record,R, ID> - Parameters:
template- the template to join.alias- the alias to use for the joined relation.- Returns:
- the query builder.
-
rightJoin
public QueryBuilder.JoinBuilder<T,Object, rightJoinID> (@Nonnull StringTemplatePREVIEW template, @Nonnull String alias) Adds a right join to the query.- Specified by:
rightJoinin classQueryBuilder<T extends Record,R, ID> - Parameters:
template- the template to join.alias- the alias to use for the joined relation.- Returns:
- the query builder.
-
join
public QueryBuilder.TypedJoinBuilder<T,Object, joinID> (@Nonnull JoinType type, @Nonnull Class<? extends Record> relation, @Nonnull String alias) Adds a join of the specified type to the query.- Specified by:
joinin classQueryBuilder<T extends Record,R, ID> - Parameters:
type- the type of the join (e.g., INNER, LEFT, RIGHT).relation- the relation to join.alias- the alias to use for the joined relation.- Returns:
- the query builder.
-
where
public QueryBuilder<T,Object, whereID> (@Nonnull Function<QueryBuilder.WhereBuilder<T, Object, ID>, QueryBuilder.PredicateBuilder<?, ?, ?>> predicate) Adds a WHERE clause to the query using aQueryBuilder.WhereBuilder.- Specified by:
wherein classQueryBuilder<T extends Record,R, ID> - Parameters:
predicate- the predicate to add.- Returns:
- the query builder.
-
DeleteBuilderImplwhen preview features are enabled.