cborm.sql

Class SQLHelper

lucee.Component
    extended by cborm.sql.SQLHelper
Class Attributes:
  • displayname : SQLHelper
  •  
  • synchronized : false
  •  
  • accessors : true
  •  
  • persistent : false
  •  
    Property Summary
    type property default serializable required
    boolean formatSql
          Format the SQL or not.

    • access = public
    • returntype = any
    false true false
    array log
          The log array.

    • access = public
    • returntype = any
    true false
    boolean returnExecutableSql
          Bit to return the executable SQL or not.

    • access = public
    • returntype = any
    false true false
    Constructor Summary
    init(any criteriaBuilder, [boolean returnExecutableSql='false'], [boolean formatSql='false'])
          Constructor.
    Method Summary
    string applyFormatting(string sql)
         Applies pretty formatting to a sql 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.
    boolean canLogLimitOffset()
    private array convertToCFArray(any array)
         Small utility method to convert weird arrays from Java methods into something CF understands.
    string generateSQLAlias()
         Generates a unique SQL Alias within the criteria query.
    private any getCriteriaJoinWalker()
         gets an instance of CriteriaJoinWalker, which can allow for translating criteria query into a sql string.
    private any getCriteriaQueryTranslator()
         gets an instance of CriteriaQueryTranslator, which can prepares criteria query for conversion to SQL.
    any getDialect()
         Retrieves the correct dialect of the database engine.
    private numeric getFirstRow(any selection)
         Gets the first row (or 0) for the current row selection.
    string getFormatSql()
    string getLog()
    private numeric getMaxOrLimit(any selection)
         Gets correct "limit" value for the current row selection.
    array getPositionalSQLParameters()
         Returns a formatted array of parameter value and types.
    any getPositionalSQLParameterTypes(boolean simple='true')
         Gets positional SQL parameter types from the criteria query.
    array getPositionalSQLParameterValues()
         Gets the positional SQL parameter values from the criteria query.
    any getProjectedTypes()
         Retrieves the projected types of the criteria query.
    string getProjectionAlias()
         Get the alias of the current projection.
    private any getQueryParameters()
         Gets currently applied query parameters for the query object.
    string getReturnExecutableSql()
    string getRootSQLAlias()
         Retrieves the "rooted" SQL alias for the criteria query.
    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.
    private boolean hasMaxRows(any selection)
         Determines whether the current row selection has a limit already applied.
    any log(string label='Criteria')
         Logs current state of criteria to internal tracking log.
    private string replaceQueryParameters(string sql)
         replace query parameter placeholders with their actual values (for detachedSQLProjection).
    any setFormatSql(boolean formatSql)
    any setLog(array log)
    any setReturnExecutableSql(boolean returnExecutableSql)
    private boolean useLimit(any selection)
         Determines whether the database engine allows for the use of "limit/offset" syntax.
     
    Methods inherited from class lucee.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:
    access - public
    required - false
    returntype - any
    serializable - true

    log

    property array log

    The log array

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    returnExecutableSql

    property boolean returnExecutableSql = [false]

    Bit to return the executable SQL or not

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    Method Detail

    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

    getFormatSql

    public string getFormatSql()


    getLog

    public string getLog()


    getMaxOrLimit

    private numeric getMaxOrLimit(any selection)

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

    Parameters:
    selection - {any} The current row selection

    getPositionalSQLParameters

    public array getPositionalSQLParameters()

    Returns a formatted array of parameter value and types return array


    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


    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


    getReturnExecutableSql

    public string getReturnExecutableSql()


    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

    setFormatSql

    public any setFormatSql(boolean formatSql)

    Parameters:
    formatSql

    setLog

    public any setLog(array log)

    Parameters:
    log

    setReturnExecutableSql

    public any setReturnExecutableSql(boolean returnExecutableSql)

    Parameters:
    returnExecutableSql

    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