Module storm

Class ORMTemplateImpl

java.lang.Object
st.orm.template.impl.ORMTemplateImpl
All Implemented Interfaces:
RepositoryLookup, ORMTemplate, QueryTemplate, SubqueryTemplate

public final class ORMTemplateImpl extends Object implements ORMTemplate
  • Field Details

  • Constructor Details

  • Method Details

    • entity

      public <T extends Record & Entity<ID>, ID> EntityRepository<T,ID> entity(@Nonnull Class<T> type)
      Returns the repository for the given entity type.
      Specified by:
      entity in interface RepositoryLookup
      Type Parameters:
      T - the entity type.
      ID - the type of the entity's primary key.
      Parameters:
      type - the entity type.
      Returns:
      the repository for the given entity type.
    • projection

      public <T extends Record & Projection<ID>, ID> ProjectionRepository<T,ID> projection(@Nonnull Class<T> type)
      Returns the repository for the given projection type.
      Specified by:
      projection in interface RepositoryLookup
      Type Parameters:
      T - the projection type.
      ID - the type of the projection's primary key, or Void if the projection specifies no primary key.
      Parameters:
      type - the projection type.
      Returns:
      the repository for the given projection type.
    • repository

      public <R extends Repository> R repository(@Nonnull Class<R> type)
      Returns a proxy for the repository of the given type.
      Specified by:
      repository in interface RepositoryLookup
      Type Parameters:
      R - the repository type.
      Parameters:
      type - the repository type.
      Returns:
      a proxy for the repository of the given type.
    • findGenericType

      public static Optional<Type> findGenericType(@Nonnull Class<?> clazz, @Nonnull Class<?> targetInterface, int typeArgumentIndex)
    • dialect

      public SqlDialect dialect()
      Get the SQL dialect for this template.
      Specified by:
      dialect in interface QueryTemplate
      Returns:
      the SQL dialect.
      Since:
      1.2
    • createBindVars

      public BindVars createBindVars()
      Create a new bind variables instance that can be used to add bind variables to a batch.
      Specified by:
      createBindVars in interface QueryTemplate
      Returns:
      a new bind variables instance.
      See Also:
    • ref

      public <E extends Record, ID> Ref<E> ref(@Nonnull Class<E> 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.
      Specified by:
      ref in interface QueryTemplate
      Type Parameters:
      E - table type.
      ID - primary key type.
      Parameters:
      type - record type.
      id - primary key.
      Returns:
      ref instance.
      Since:
      1.3
    • ref

      public <E extends Record, ID> Ref<E> ref(@Nonnull E entity, @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. The object returned by this method already contains the fetched record.
      Specified by:
      ref in interface QueryTemplate
      Type Parameters:
      E - table type.
      ID - primary key type.
      Parameters:
      id - primary key.
      Returns:
      ref instance.
      Since:
      1.3
    • model

      public <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.
      Specified by:
      model in interface QueryTemplate
      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

      public <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.
      Specified by:
      selectFrom in interface QueryTemplate
      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

      public <T extends Record> QueryBuilder<T,?,?> deleteFrom(@Nonnull Class<T> fromType)
      Creates a query builder for the specified table to delete from.
      Specified by:
      deleteFrom in interface QueryTemplate
      Type Parameters:
      T - the table type to delete from.
      Parameters:
      fromType - the table to delete from.
      Returns:
      the query builder.
    • subquery

      public <T extends Record> QueryBuilder<T,?,?> subquery(@Nonnull Class<T> fromType, @Nonnull StringTemplatePREVIEW template)
      Create a subquery for the given table and select type using the given template.
      Specified by:
      subquery in interface SubqueryTemplate
      Type Parameters:
      T - the table type to select from.
      Parameters:
      fromType - the table to create the subquery for.
      template - the select clause template.
      Returns:
      the subquery builder.
    • query

      public Query query(@Nonnull StringTemplatePREVIEW template)
      Creates a query for the specified query template.
      Specified by:
      query in interface QueryTemplate
      Parameters:
      template - the query template.
      Returns:
      the query.