Class SqlFileScriptQuery

java.lang.Object
org.seasar.doma.jdbc.query.AbstractQuery
org.seasar.doma.jdbc.query.SqlFileScriptQuery
All Implemented Interfaces:
Query, ScriptQuery

public class SqlFileScriptQuery extends AbstractQuery implements ScriptQuery
A query that executes a SQL script file.

This class extends AbstractQuery to provide functionality for executing SQL script files. It handles script file loading, block delimiter detection, and script execution.

  • Field Details

    • scriptFilePath

      protected String scriptFilePath
      The path to the script file.
    • blockDelimiter

      protected String blockDelimiter
      The delimiter that separates SQL statements in the script.
    • haltOnError

      protected boolean haltOnError
      Whether to halt execution when an error occurs.
    • scriptFileUrl

      protected URL scriptFileUrl
      The URL of the script file.
    • sqlAnnotation

      protected Sql sqlAnnotation
      The SQL annotation if the script is defined inline.
    • sqlLogType

      protected SqlLogType sqlLogType
      The SQL log type for this script query.
  • Constructor Details

    • SqlFileScriptQuery

      public SqlFileScriptQuery()
  • Method Details

    • setScriptFilePath

      public void setScriptFilePath(String scriptFilePath)
      Sets the path to the script file.
      Parameters:
      scriptFilePath - the script file path
    • setBlockDelimiter

      public void setBlockDelimiter(String blockDelimiter)
      Sets the delimiter that separates SQL statements in the script.
      Parameters:
      blockDelimiter - the block delimiter
    • setHaltOnError

      public void setHaltOnError(boolean haltOnError)
      Sets whether to halt execution when an error occurs.
      Parameters:
      haltOnError - whether to halt on error
    • setSqlLogType

      public void setSqlLogType(SqlLogType sqlLogType)
      Sets the SQL log type for this script query.
      Parameters:
      sqlLogType - the SQL log type
    • prepare

      public void prepare()
      Prepares this query for execution. This method must be called before the query is executed.
      Specified by:
      prepare in interface Query
      Overrides:
      prepare in class AbstractQuery
    • complete

      public void complete()
      Completes this query after execution. This method must be called after the query is executed.
      Specified by:
      complete in interface Query
    • getQueryTimeout

      public int getQueryTimeout()
      Returns the query timeout in seconds.
      Specified by:
      getQueryTimeout in interface Query
      Overrides:
      getQueryTimeout in class AbstractQuery
      Returns:
      the query timeout
    • getSql

      public Sql<?> getSql()
      Returns the SQL object that represents the query.
      Specified by:
      getSql in interface Query
      Returns:
      the SQL object
    • getScriptFilePath

      public String getScriptFilePath()
      Returns the path of the script file.
      Specified by:
      getScriptFilePath in interface ScriptQuery
      Returns:
      the script file path
    • getScriptFileUrl

      public URL getScriptFileUrl()
      Returns the URL of the script file.
      Specified by:
      getScriptFileUrl in interface ScriptQuery
      Returns:
      the URL of the script file
    • getReaderSupplier

      public Supplier<Reader> getReaderSupplier()
      Returns a supplier that provides a reader for the script content.
      Specified by:
      getReaderSupplier in interface ScriptQuery
      Returns:
      the reader supplier
    • getBlockDelimiter

      public String getBlockDelimiter()
      Returns the delimiter that separates SQL statements in the script.
      Specified by:
      getBlockDelimiter in interface ScriptQuery
      Returns:
      the block delimiter
    • getHaltOnError

      public boolean getHaltOnError()
      Returns whether execution should halt on error.
      Specified by:
      getHaltOnError in interface ScriptQuery
      Returns:
      true if execution should halt on error
    • getSqlLogType

      public SqlLogType getSqlLogType()
      Returns the SQL log type for this script query.
      Specified by:
      getSqlLogType in interface ScriptQuery
      Returns:
      the SQL log type