Interface SchemaResolver

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface SchemaResolver
Resolves the schema a table lives in, per template.

The schema an entity declares with @DbTable(schema = ...) is fixed at compile time, while the schema a table actually lives in can depend on the database a template connects to: two templates may reach the same tables under different schema names. A template's schema resolver maps the declared schema, or the absence of one, to the schema its statements address.

Since:
1.15
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final SchemaResolver
    The default schema resolver, which addresses the schema the entity declares.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a schema resolver that maps declared schemas to other names, and leaves every schema it does not name as declared.
    resolveSchema(Class<?> type, String schema)
    Resolves the schema of the table the given type maps to.
  • Field Details

    • DEFAULT

      static final SchemaResolver DEFAULT
      The default schema resolver, which addresses the schema the entity declares.
  • Method Details

    • mapping

      static SchemaResolver mapping(Map<String,String> schemas)
      Returns a schema resolver that maps declared schemas to other names, and leaves every schema it does not name as declared. Resolvers created from equal mappings are equal, so templates configured alike share the models Storm caches for them.
      Parameters:
      schemas - the declared schemas, mapped to the schemas to address instead.
      Returns:
      the schema resolver.
    • resolveSchema

      String resolveSchema(Class<?> type, String schema)
      Resolves the schema of the table the given type maps to.
      Parameters:
      type - the entity or projection type.
      schema - the schema the type declares, or an empty string if it declares none.
      Returns:
      the schema to address, or an empty string to address the table without a schema.