Module storm

Interface QueryTemplate

All Superinterfaces:
SubqueryTemplate
All Known Subinterfaces:
ORMTemplate
All Known Implementing Classes:
ORMTemplateImpl

public interface QueryTemplate extends SubqueryTemplate
QueryTemplate relies on preview features of the Java platform:
Programs can only use QueryTemplate when preview features are enabled.
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 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

      <T extends Record, ID> Ref<T> ref(@Nonnull Class<T> type, @Nonnull ID id)
      Creates a ref instance for the specified record type and pk. 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

      <T extends Record, ID> Ref<T> ref(@Nonnull T record, @Nonnull ID id)
      Creates a ref instance for the specified record type and id. 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

      default <T extends Record, ID> Model<T,ID> model(@Nonnull Class<T> type)
      Get the model for the specified record type. 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

      <T extends Record, ID> Model<T,ID> model(@Nonnull Class<T> type, boolean requirePrimaryKey)
      Get the model for the specified record type. 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

      default <T extends Record> QueryBuilder<T,T,?> selectFrom(@Nonnull Class<T> fromType)
      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 given template.
      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

      <T extends Record> QueryBuilder<T,?,?> deleteFrom(@Nonnull Class<T> fromType)
      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

      Query query(@Nonnull StringTemplatePREVIEW template)
      Creates a query for the specified query template.
      Parameters:
      template - the query template.
      Returns:
      the query.