private List getCreateTableStrings()

in google-cloud-spanner-hibernate-dialect/src/main/java/com/google/cloud/spanner/hibernate/schema/SpannerTableStatements.java [131:170]


  private List<String> getCreateTableStrings(
      Table table, Metadata metadata, java.util.Collection<Column> keyColumns) {

    // Get the comma separated string of the primary keys of the table.
    String primaryKeyColNames =
        keyColumns.stream().map(Column::getQuotedName).collect(Collectors.joining(","));

    // Get the comma separated string of all columns of the table.
    String allColumnNames =
        table.getColumns().stream()
            .map(column -> buildColumnTypeString(column, metadata))
            .collect(Collectors.joining(","));

    ArrayList<String> statements = new ArrayList<>();

    // Build the Create Table string.
    String createTableString =
        MessageFormat.format(
            CREATE_TABLE_TEMPLATE,
            table.getQualifiedTableName(),
            allColumnNames,
            primaryKeyColNames,
            getInterleavedClause(table, metadata));

    statements.add(createTableString);

    if (table.getName().equals(SequenceStyleGenerator.SEQUENCE_PARAM)) {
      // Caches the INSERT statement since DML statements must be run after a DDL batch.
      table.addInitCommand(
          context ->
              new ReplaceInitCommand(
                  "INSERT INTO "
                      + context.format(table.getQualifiedTableName())
                      + " ("
                      + SequenceStyleGenerator.DEF_VALUE_COLUMN
                      + ") VALUES(1)"));
    }

    return statements;
  }