- All Superinterfaces:
SubqueryTemplate
- All Known Subinterfaces:
ORMTemplate
- All Known Implementing Classes:
ORMTemplateImpl
QueryTemplate relies on preview features of the Java platform:
QueryTemplaterefers to one or more preview APIs:StringTemplate.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
The query template is used to construct queries.
-
Method Summary
Modifier and TypeMethodDescriptionCreate a new bind variables instance that can be used to add bind variables to a batch.<T extends Record>
QueryBuilder<T, ?, ?> deleteFrom(Class<T> fromType) Creates a query builder for the specified table to delete from.dialect()Get the SQL dialect for this template.Get the model for the specified recordtype.Get the model for the specified recordtype.query(StringTemplatePREVIEW template) Creates a query for the specified querytemplate.Creates a ref instance for the specified recordtypeandpk.ref(T record, ID id) Creates a ref instance for the specified recordtypeandid.default <T extends Record>
QueryBuilder<T, T, ?> selectFrom(Class<T> fromType) Creates a query builder for the specified table.default <T extends Record,R extends Record>
QueryBuilder<T, R, ?> selectFrom(Class<T> fromType, Class<R> selectType) Creates a query builder for the specified table and select type.<T extends Record,R>
QueryBuilder<T, R, ?> selectFrom(Class<T> fromType, Class<R> selectType, StringTemplatePREVIEW template) Creates a query builder for the specified table and select type using the giventemplate.Methods inherited from interface st.orm.template.SubqueryTemplate
subquery, subquery, subquery
-
Method Details
-
dialect
SqlDialect dialect()Get the SQL dialect for this template.- Returns:
- the SQL dialect.
- Since:
- 1.2
-
createBindVars
BindVars createBindVars()Create a new bind variables instance that can be used to add bind variables to a batch.- Returns:
- a new bind variables instance.
- See Also:
-
ref
Creates a ref instance for the specified recordtypeandpk. This method can be used to generate ref instances for entities, projections and regular records.- Type Parameters:
T- table type.ID- primary key type.- Parameters:
type- record type.id- primary key.- Returns:
- ref instance.
- Since:
- 1.3
-
ref
Creates a ref instance for the specified recordtypeandid. This method can be used to generate ref instances for entities, projections and regular records. The object returned by this method already contains the fetched record.- Type Parameters:
T- table type.ID- primary key type.- Parameters:
id- primary key.- Returns:
- ref instance.
- Since:
- 1.3
-
model
Get the model for the specified recordtype. The model provides information about the type's database name, primary keys and columns.- Type Parameters:
T- table type.ID- primary key type.- Parameters:
type- record type.- Returns:
- the model.
-
model
Get the model for the specified recordtype. The model provides information about the type's database name, primary keys and columns.- Type Parameters:
T- table type.ID- primary key type.- Parameters:
type- record type.requirePrimaryKey- whether to require a primary key.- Returns:
- the model.
- Since:
- 1.3
-
selectFrom
Creates a query builder for the specified table.- Type Parameters:
T- the table type to select from.- Parameters:
fromType- the table to select from.- Returns:
- the query builder.
-
selectFrom
default <T extends Record,R extends Record> QueryBuilder<T,R, selectFrom?> (@Nonnull Class<T> fromType, @Nonnull Class<R> selectType) Creates a query builder for the specified table and select type.- Type Parameters:
T- the table type to select from.R- the result type.- Parameters:
fromType- the table to select from.selectType- the result type of the query.- Returns:
- the query builder.
-
selectFrom
<T extends Record,R> QueryBuilder<T,R, selectFrom?> (@Nonnull Class<T> fromType, @Nonnull Class<R> selectType, @Nonnull StringTemplatePREVIEW template) Creates a query builder for the specified table and select type using the giventemplate.- Type Parameters:
T- the table type to select from.R- the result type.- Parameters:
fromType- the table to select from.selectType- the result type of the query.template- the select clause template.- Returns:
- the query builder.
-
deleteFrom
Creates a query builder for the specified table to delete from.- Type Parameters:
T- the table type to delete from.- Parameters:
fromType- the table to delete from.- Returns:
- the query builder.
-
query
Creates a query for the specified querytemplate.- Parameters:
template- the query template.- Returns:
- the query.
-
QueryTemplatewhen preview features are enabled.