protected void applyInitCommands()

in google-cloud-spanner-hibernate-dialect/src/main/java/com/google/cloud/spanner/hibernate/SpannerTableExporter.java [73:91]


  protected void applyInitCommands(
      Table table, Metadata metadata, SqlStringGenerationContext context) {
    List<InitCommand> initCommands = table.getInitCommands(context);
    // Use only the replaced commands if the list contains both normal InitCommands and
    // ReplaceInitCommands.
    if (initCommands.stream().anyMatch(ReplaceInitCommand.class::isInstance)
        && initCommands.stream().anyMatch(cmd -> !ReplaceInitCommand.class.isInstance(cmd))) {
      initCommands =
          initCommands.stream()
              .filter(ReplaceInitCommand.class::isInstance)
              .collect(Collectors.toList());
    } else if (initCommands.stream().anyMatch(ReplaceInitCommand.class::isInstance)) {
      // Only ReplaceInitCommands, but there is nothing to replace, so we return early.
      return;
    }
    for (InitCommand initCommand : initCommands) {
      addStatementAfterDdlBatch(metadata, initCommand.getInitCommands());
    }
  }