coldbox.system.orm.hibernate.sql

Class SQLHelper

WEB-INF.cftags.component
        extended by coldbox.system.orm.hibernate.sql.SQLHelper
Class Attributes:
  • accessors : true
  •  
  • displayname : SQLHelper
  •  
    Property Summary
    type property default serializable required
    boolean formatSql
          Format the SQL or not.

    false true false
    array log
          The log array.

    true false
    boolean returnExecutableSql
          Bit to return the executable SQL or not.

    false true false
    Constructor Summary
    init(any criteriaBuilder, [boolean returnExecutableSql='false'], [boolean formatSql='false'])
          Constructor.
    Method Summary
    boolean GETFORMATSQL()
         get: Format the SQL or not.
    array GETLOG()
         get: The log array.
    boolean GETRETURNEXECUTABLESQL()
         get: Bit to return the executable SQL or not.
    SQLHelper SETFORMATSQL(boolean formatSql)
         set: Format the SQL or not.
    SQLHelper SETLOG(array log)
         set: The log array.
    SQLHelper SETRETURNEXECUTABLESQL(boolean returnExecutableSql)
         set: Bit to return the executable SQL or not.
    string applyFormatting(string sql)
         Applies pretty formatting to a sql string return string.
    private Array bindLimitParameters(Array positionalValues, Boolean append, any selection)
         Inserts parameter values into the running list based on the dialect of the database engine return Array.
    Boolean canLogLimitOffset()
    private array convertToCFArray(any array)
         Small utility method to convert weird arrays from Java methods into something CF understands return Array.
    string generateSQLAlias()
         Generates a unique SQL Alias within the criteria query return string.
    private any getCriteriaJoinWalker()
         gets an instance of CriteriaJoinWalker, which can allow for translating criteria query into a sql string returns CriteriaJoinWalker.
    private any getCriteriaQueryTranslator()
         gets an instance of CriteriaQueryTranslator, which can prepares criteria query for conversion to SQL returns CriteriaQueryTranslator.
    any getDialect()
         Retrieves the correct dialect of the database engine return any.
    private Numeric getFirstRow(any selection)
         Gets the first row (or 0) for the current row selection return Numeric.
    private Numeric getMaxOrLimit(any selection)
         Gets correct "limit" value for the current row selection return Numeric.
    any getPositionalSQLParameterTypes(Boolean simple='true')
         Gets positional SQL parameter types from the criteria query return any.
    array getPositionalSQLParameterValues()
         Gets the positional SQL parameter values from the criteria query return array.
    Array getPositionalSQLParameters()
         Returns a formatted array of parameter value and types return array.
    any getProjectedTypes()
         Retrieves the projected types of the criteria query return string.
    string getProjectionAlias()
         Get the alias of the current projection return string.
    private any getQueryParameters()
         Gets currently applied query parameters for the query object return org.
    string getRootSQLAlias()
         Retrieves the "rooted" SQL alias for the criteria query return string.
    string getSQL(boolean returnExecutableSql='[runtime expression]', boolean formatSql='[runtime expression]')
         Returns the SQL string that will be prepared for the criteria object at the time of request return string.
    private Boolean hasMaxRows(any selection)
         Determines whether the current row selection has a limit already applied return Boolean.
    any log(string label='Criteria')
         Logs current state of criteria to internal tracking log return void.
    private string replaceQueryParameters(string sql)
         replace query parameter placeholders with their actual values (for detachedSQLProjection) returns string.
    private Boolean useLimit(any selection)
         Determines whether the database engine allows for the use of "limit/offset" syntax return Boolean.
     
    Methods inherited from class WEB-INF.cftags.component
    None

    Constructor Detail

    init

    public init(any criteriaBuilder, [boolean returnExecutableSql='false'], [boolean formatSql='false'])

    Constructor

    Parameters:
    criteriaBuilder
    returnExecutableSql
    formatSql

    Property Detail

    formatSql

    property boolean formatSql = [false]

    Format the SQL or not.

    Attributes:
    serializable - true
    required - false

    log

    property array log

    The log array

    Attributes:
    serializable - true
    required - false

    returnExecutableSql

    property boolean returnExecutableSql = [false]

    Bit to return the executable SQL or not

    Attributes:
    serializable - true
    required - false

    Method Detail

    GETFORMATSQL

    public boolean GETFORMATSQL()

    get: Format the SQL or not.


    GETLOG

    public array GETLOG()

    get: The log array


    GETRETURNEXECUTABLESQL

    public boolean GETRETURNEXECUTABLESQL()

    get: Bit to return the executable SQL or not


    SETFORMATSQL

    public SQLHelper SETFORMATSQL(boolean formatSql)

    set: Format the SQL or not.

    Parameters:
    formatSql

    SETLOG

    public SQLHelper SETLOG(array log)

    set: The log array

    Parameters:
    log

    SETRETURNEXECUTABLESQL

    public SQLHelper SETRETURNEXECUTABLESQL(boolean returnExecutableSql)

    set: Bit to return the executable SQL or not

    Parameters:
    returnExecutableSql

    applyFormatting

    public string applyFormatting(string sql)

    Applies pretty formatting to a sql string return string

    Parameters:
    sql - {string} The SQL string to format

    bindLimitParameters

    private Array bindLimitParameters(Array positionalValues, Boolean append, any selection)

    Inserts parameter values into the running list based on the dialect of the database engine return Array

    Parameters:
    positionalValues - {Array} The positional values for this query
    append - {Boolean} Whether values are appended or prepended to the array
    selection - {any} The current row selection

    canLogLimitOffset

    public Boolean canLogLimitOffset()


    convertToCFArray

    private array convertToCFArray(any array)

    Small utility method to convert weird arrays from Java methods into something CF understands return Array

    Parameters:
    array - {Array} The array to convert

    generateSQLAlias

    public string generateSQLAlias()

    Generates a unique SQL Alias within the criteria query return string


    getCriteriaJoinWalker

    private any getCriteriaJoinWalker()

    gets an instance of CriteriaJoinWalker, which can allow for translating criteria query into a sql string returns CriteriaJoinWalker


    getCriteriaQueryTranslator

    private any getCriteriaQueryTranslator()

    gets an instance of CriteriaQueryTranslator, which can prepares criteria query for conversion to SQL returns CriteriaQueryTranslator


    getDialect

    public any getDialect()

    Retrieves the correct dialect of the database engine return any


    getFirstRow

    private Numeric getFirstRow(any selection)

    Gets the first row (or 0) for the current row selection return Numeric

    Parameters:
    selection - {any} The current row selection

    getMaxOrLimit

    private Numeric getMaxOrLimit(any selection)

    Gets correct "limit" value for the current row selection return Numeric

    Parameters:
    selection - {any} The current row selection

    getPositionalSQLParameterTypes

    public any getPositionalSQLParameterTypes(Boolean simple='true')

    Gets positional SQL parameter types from the criteria query return any

    Parameters:
    simple - {Boolean} Whether to return a simply array or full objects

    getPositionalSQLParameterValues

    public array getPositionalSQLParameterValues()

    Gets the positional SQL parameter values from the criteria query return array


    getPositionalSQLParameters

    public Array getPositionalSQLParameters()

    Returns a formatted array of parameter value and types return array


    getProjectedTypes

    public any getProjectedTypes()

    Retrieves the projected types of the criteria query return string


    getProjectionAlias

    public string getProjectionAlias()

    Get the alias of the current projection return string


    getQueryParameters

    private any getQueryParameters()

    Gets currently applied query parameters for the query object return org.hibernate.engine.QueryParameters


    getRootSQLAlias

    public string getRootSQLAlias()

    Retrieves the "rooted" SQL alias for the criteria query return string


    getSQL

    public string getSQL(boolean returnExecutableSql='[runtime expression]', boolean formatSql='[runtime expression]')

    Returns the SQL string that will be prepared for the criteria object at the time of request return string

    Parameters:
    returnExecutableSql - {Boolean} Whether or not to do query param replacements on returned SQL string
    formatSql - {Boolean} Whether to format the sql

    hasMaxRows

    private Boolean hasMaxRows(any selection)

    Determines whether the current row selection has a limit already applied return Boolean

    Parameters:
    selection - {any} The current row selection

    log

    public any log(string label='Criteria')

    Logs current state of criteria to internal tracking log return void

    Parameters:
    label - {string} The label for the log record

    replaceQueryParameters

    private string replaceQueryParameters(string sql)

    replace query parameter placeholders with their actual values (for detachedSQLProjection) returns string

    Parameters:
    sql - (string) The sql string to massage

    useLimit

    private Boolean useLimit(any selection)

    Determines whether the database engine allows for the use of "limit/offset" syntax return Boolean

    Parameters:
    selection - {any} The current row selection