Module storm.java

Class ORMTemplateImpl

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

public final class ORMTemplateImpl extends QueryTemplateImpl implements ORMTemplate
  • Constructor Details

    • ORMTemplateImpl

      public ORMTemplateImpl(st.orm.core.template.ORMTemplate core)
  • Method Details

    • withEntityCallback

      public ORMTemplate withEntityCallback(EntityCallback<?> callback)
      Description copied from interface: ORMTemplate
      Returns a new ORMTemplate with the specified entity callback added.

      The returned template shares the same underlying connection and configuration, but applies the given callback to entity lifecycle operations (insert, update, delete) performed through its repositories. The callback is only invoked for entities matching its type parameter. Multiple callbacks can be registered by chaining calls to this method.

      Specified by:
      withEntityCallback in interface ORMTemplate
      Parameters:
      callback - the entity callback to add; must not be null.
      Returns:
      a new ORMTemplate with the callback added.
    • withEntityCallbacks

      public ORMTemplate withEntityCallbacks(List<EntityCallback<?>> callbacks)
      Description copied from interface: ORMTemplate
      Returns a new ORMTemplate with the specified entity callbacks added.

      The returned template shares the same underlying connection and configuration, but applies the given callbacks to entity lifecycle operations (insert, update, delete) performed through its repositories. Each callback is only invoked for entities matching its type parameter.

      Specified by:
      withEntityCallbacks in interface ORMTemplate
      Parameters:
      callbacks - the entity callbacks to add; must not be null.
      Returns:
      a new ORMTemplate with the callbacks added.
    • validateSchema

      public List<String> validateSchema()
      Description copied from interface: ORMTemplate
      Validates all discovered entity and projection types against the database schema.

      Logs each validation error and returns the list of error messages. On success, logs a confirmation message and returns an empty list.

      This method requires a DataSource-backed template. Templates created from a raw Connection or EntityManager do not support schema validation.

      Specified by:
      validateSchema in interface ORMTemplate
      Returns:
      the list of validation error messages (empty on success).
    • validateSchema

      public List<String> validateSchema(Predicate<Class<? extends Data>> filter)
      Description copied from interface: ORMTemplate
      Validates discovered types matching the filter against the database schema.

      Discovers all entity and projection types via the classpath index, applies the given filter, and validates the matching types. This is useful when a single application connects to multiple datasources and only a subset of types is reachable from each connection.

      Logs each validation error and returns the list of error messages. On success, logs a confirmation message and returns an empty list.

      This method requires a DataSource-backed template. Templates created from a raw Connection or EntityManager do not support schema validation.

      Specified by:
      validateSchema in interface ORMTemplate
      Parameters:
      filter - predicate to select which discovered types to validate.
      Returns:
      the list of validation error messages (empty on success).
    • validateSchema

      public List<String> validateSchema(Iterable<Class<? extends Data>> types)
      Description copied from interface: ORMTemplate
      Validates the specified types against the database schema.

      Logs each validation error and returns the list of error messages. On success, logs a confirmation message and returns an empty list.

      This method requires a DataSource-backed template. Templates created from a raw Connection or EntityManager do not support schema validation.

      Specified by:
      validateSchema in interface ORMTemplate
      Parameters:
      types - the entity and projection types to validate.
      Returns:
      the list of validation error messages (empty on success).
    • validateSchemaOrThrow

      public void validateSchemaOrThrow()
      Description copied from interface: ORMTemplate
      Validates all discovered types and throws if any errors are found.

      This method requires a DataSource-backed template. Templates created from a raw Connection or EntityManager do not support schema validation.

      Specified by:
      validateSchemaOrThrow in interface ORMTemplate
    • validateSchemaOrThrow

      public void validateSchemaOrThrow(Predicate<Class<? extends Data>> filter)
      Description copied from interface: ORMTemplate
      Validates discovered types matching the filter and throws if any errors are found.

      Discovers all entity and projection types via the classpath index, applies the given filter, and validates the matching types. This is useful when a single application connects to multiple datasources and only a subset of types is reachable from each connection.

      This method requires a DataSource-backed template. Templates created from a raw Connection or EntityManager do not support schema validation.

      Specified by:
      validateSchemaOrThrow in interface ORMTemplate
      Parameters:
      filter - predicate to select which discovered types to validate.
    • validateSchemaOrThrow

      public void validateSchemaOrThrow(Iterable<Class<? extends Data>> types)
      Description copied from interface: ORMTemplate
      Validates the specified types and throws if any errors are found.

      This method requires a DataSource-backed template. Templates created from a raw Connection or EntityManager do not support schema validation.

      Specified by:
      validateSchemaOrThrow in interface ORMTemplate
      Parameters:
      types - the entity and projection types to validate.
    • writeSet

      public WriteSet writeSet()
      Description copied from interface: RepositoryLookup
      Returns dependency-aware write operations over mixed-type sets of entities.

      A write set lifts the per-repository write actions to collections spanning multiple entity types: entities are partitioned by type, ordered by their foreign key dependencies, and written with one batch statement per type per dependency level. Generated primary keys propagate to dependent entities within the set.

      Specified by:
      writeSet in interface RepositoryLookup
      Returns:
      the write set operations bound to this lookup.
      See Also:
    • entity

      public <T extends Entity<ID>, ID> EntityRepository<T,ID> entity(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 Projection<ID>, ID> ProjectionRepository<T,ID> projection(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(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.