Package io.ebean

Interface ScriptRunner


  • public interface ScriptRunner
    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");
    
     
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void run​(String path)
      Run a script given the resource path (that should start with "/").
      void run​(String path, Map<String,​String> placeholderMap)
      Run a script given the resource path (that should start with "/") and place holders.
      void run​(URL resource)
      Run a DDL or SQL script given the resource.
      void run​(URL resource, Map<String,​String> placeholderMap)
      Run a DDL or SQL script given the resource and place holders.
      void runScript​(String name, String content, boolean useAutoCommit)
      Run the raw provided DDL or SQL script.
    • Method Detail

      • run

        void run​(String path)
        Run a script given the resource path (that should start with "/").
      • run

        void run​(String path,
                 Map<String,​String> placeholderMap)
        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

        void run​(URL resource)
        Run a DDL or SQL script given the resource.
      • run

        void run​(URL resource,
                 Map<String,​String> placeholderMap)
        Run a DDL or SQL script given the resource and place holders.
      • runScript

        void runScript​(String name,
                       String content,
                       boolean useAutoCommit)
        Run the raw provided DDL or SQL script.
        Parameters:
        name - The name of the script for logging purposes
        content - The SQL content
        useAutoCommit - Set to true to use auto commit true and continue when any errors occur