package io.ebean;

import java.net.URL;
import java.util.Map;

Runs DDL and SQL scripts.

Typically these are scripts used for testing such as seed SQL scripts or truncate SQL scripts.

Scripts are executed in their own transaction and committed on successful completion.

Example of simple use


  Database database = DB.getDefault();
  database.script().run("/scripts/test-script.sql");
/** * Runs DDL and SQL scripts. * <p/> * Typically these are scripts used for testing such as seed SQL scripts or truncate SQL scripts. * <p/> * Scripts are executed in their own transaction and committed on successful completion. * * <h3>Example of simple use</h3> * <pre>{@code * * Database database = DB.getDefault(); * database.script().run("/scripts/test-script.sql"); * * }</pre> */
public interface ScriptRunner {
Run a script given the resource path (that should start with "/").
/** * Run a script given the resource path (that should start with "/"). */
void run(String path);
Run a script given the resource path (that should start with "/") and place holders.

  Map<String,String> placeholders = new HashMap<>();
  placeholders.put("tableName", "e_basic");
  Database database = DB.getDefault();
  database.script().run("/scripts/test-script.sql", placeholders);
/** * Run a script given the resource path (that should start with "/") and place holders. * * <pre>{@code * * Map<String,String> placeholders = new HashMap<>(); * placeholders.put("tableName", "e_basic"); * * Database database = DB.getDefault(); * database.script().run("/scripts/test-script.sql", placeholders); * * }</pre> */
void run(String path, Map<String, String> placeholderMap);
Run a DDL or SQL script given the resource.
/** * Run a DDL or SQL script given the resource. */
void run(URL resource);
Run a DDL or SQL script given the resource and place holders.
/** * Run a DDL or SQL script given the resource and place holders. */
void run(URL resource, Map<String, String> placeholderMap); }