mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
66 lines
1.6 KiB
Java
66 lines
1.6 KiB
Java
package io.ebean;
|
|
|
|
import java.net.URL;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* 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
|
|
*
|
|
* EbeanServer server = Ebean.getDefaultServer();
|
|
* server.script().run("/scripts/test-script.sql");
|
|
*
|
|
* }</pre>
|
|
*
|
|
*
|
|
* <h3>Example using place holders in the script</h3>
|
|
* <pre>{@code
|
|
*
|
|
* Map<String,String> placeholders = new HashMap<>();
|
|
* placeholders.put("tableName", "e_basic");
|
|
*
|
|
* EbeanServer server = Ebean.getDefaultServer();
|
|
* server.script().run("/scripts/test-script.sql");
|
|
*
|
|
* }</pre>
|
|
*/
|
|
public interface ScriptRunner {
|
|
|
|
/**
|
|
* 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.
|
|
*
|
|
* <pre>{@code
|
|
*
|
|
* Map<String,String> placeholders = new HashMap<>();
|
|
* placeholders.put("tableName", "e_basic");
|
|
*
|
|
* EbeanServer server = Ebean.getDefaultServer();
|
|
* server.script().run("/scripts/test-script.sql");
|
|
*
|
|
* }</pre>
|
|
*/
|
|
void run(String path, Map<String, String> placeholderMap);
|
|
|
|
/**
|
|
* 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.
|
|
*/
|
|
void run(URL resource, Map<String, String> placeholderMap);
|
|
|
|
}
|