Class SpannerSchemaUtils


public class SpannerSchemaUtils extends Object
Contains functions related to the table schema of entities.
  • Constructor Details

    • SpannerSchemaUtils

      public SpannerSchemaUtils(SpannerMappingContext mappingContext, SpannerEntityProcessor spannerEntityProcessor, boolean createInterleavedTableDdlOnDeleteCascade)
      Constructor. Generates create-table DDL statements that cascade deletes for interleaved tables.
      mappingContext - a mapping context used to obtain persistent entity metadata for generating DDL statements.
      spannerEntityProcessor - an entity processor that is queried for types that it can convert for determining compatible column types when generating DDL statements.
      createInterleavedTableDdlOnDeleteCascade - if true will generate create-table statements that specify cascade on delete for interleaved tables. If false, then the deletes among interleaved tables do not cascade and require manual deletion of all children before parents.
  • Method Details

    • getDropTableDdlString

      public String getDropTableDdlString(Class entityClass)
      Gets the DDL string to drop the table for the given entity in Cloud Spanner.
      entityClass - the entity type.
      the DDL string.
    • getKey

      public getKey(Object object)
      Gets the key for the given object.
      object - the object to get the key for
      the Spanner Key for the given object.
    • getCreateTableDdlString

      public <T> String getCreateTableDdlString(Class<T> entityClass)
      Gets the DDL string to create the table for the given entity in Cloud Spanner. This is just one of the possible schemas that can support the given entity type. The specific schema is determined by the configured property type converters used by the read and write methods in this SpannerOperations and will be compatible with those methods.
      Type Parameters:
      T - the type of the entity class
      entityClass - the entity type.
      the DDL string.
    • getCreateTableDdlStringsForInterleavedHierarchy

      public List<String> getCreateTableDdlStringsForInterleavedHierarchy(Class entityClass)
      Gets a list of DDL strings to create the tables rooted at the given entity class. The DDL-create strings are ordered in the list starting with the given root class and are topologically sorted.
      entityClass - the root class for which to get create strings.
      a list of create strings that are toplogically sorted from parents to children.
    • getDropTableDdlStringsForInterleavedHierarchy

      public List<String> getDropTableDdlStringsForInterleavedHierarchy(Class entityClass)
      Gets the DDL strings to drop the tables of this entity and all of its sub-entities. The list is given in reverse topological sort, since parent tables cannot be dropped before their children tables.
      entityClass - the root entity whose table to drop.
      the list of drop DDL strings.