coldbox.system.orm.hibernate

Class BaseBuilder

WEB-INF.cftags.component
        extended by coldbox.system.orm.hibernate.BaseBuilder
Class Attributes:
  • accessors : true
  •  
    Direct Known Subclasses:
    CriteriaBuilder , DetachedCriteriaBuilder
    Property Summary
    type property default serializable required
    boolean SQLLoggerActive
          The bit that determines if we are tracking SQL.

    false true false
    string entityName
          The entity name this criteria builder is binded to.

    true false
    any eventManager
          The system event manager.

    true false
    any nativeCriteria
          The native criteria object.

    true false
    Constructor Summary
    init(string entityName, any criteria, any restrictions, any ORMService)
    Method Summary
    string GETENTITYNAME()
         get: The entity name this criteria builder is binded to.
    any GETEVENTMANAGER()
         get: The system event manager.
    any GETNATIVECRITERIA()
         get: The native criteria object.
    boolean GETSQLLOGGERACTIVE()
         get: The bit that determines if we are tracking SQL.
    BaseBuilder SETEVENTMANAGER(any eventManager)
         set: The system event manager.
    BaseBuilder SETSQLLOGGERACTIVE(boolean SQLLoggerActive)
         set: The bit that determines if we are tracking SQL.
    any add(any criterion)
         Add a restriction to constrain the results to be retrieved.
    private any addProjection([any propertyName], [any projectionType], [any projectionList])
    boolean canLogSql()
         Returns whether or not CriteriaBuilder is currently configured to log SQL return Boolean.
    any convertIDValueToJavaType(any id)
         Coverts an ID, list of ID's, or array of ID's values to the proper java type The method returns a coverted array of ID's.
    any convertValueToJavaType(any propertyName, any value)
         Coverts a value to the correct javaType for the property passed in The method returns the value in the proper Java Type.
    any createAlias(string associationName, string alias, [numeric joinType])
         Join an association, assigning an alias to the joined association.
    any createCriteria(string associationName, [numeric joinType])
         Create a new Criteria, "rooted" at the associated entity and using an Inner Join.
    private any createRestriction(string missingMethodName, struct missingMethodArguments)
    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.
    string getSQL(boolean returnExecutableSql='false', boolean formatSql='true')
         Returns the SQL string that will be prepared for the criteria object at the time of request return string.
    array getSQLLog()
         Retrieves the SQL Log return Array.
    private boolean hasProjection()
         Checks whether or not a projection is currently applied to the CriteriaBuilder return Boolean.
    void logSQL(String label)
         Allows for one-off sql logging at any point in the process of building up CriteriaBuilder; will log the SQL state at the time of the call return void.
    private void normalizeOrder(string sortOrder, boolean ignoreCase)
    any order(string property, [string sortDir='asc'], [boolean ignoreCase='false'])
         Add an ordering to the result set, you can add as many as you like.
    private struct prepareSQLProjection([any rawProjection])
         Helper method to prepare sqlProjection for addition to CriteriaBuilder return Struct.
    any resultTransformer([any resultTransformer])
         Sets a valid hibernate result transformer: org.
    any setEntityName(any entityName)
         set: The entity name this criteria builder is binded to.
    any setNativeCriteria(any criteria)
         set: The native criteria object.
    any setProjection([any projection])
         Setup a single or a projection list via native projections class: criteria.
    any startSqlLog(Any returnExecutableSql='false', Any formatSql='false')
         Triggers CriteriaBuilder to start internally logging the state of SQL at each iterative build return CriteriaBuilder.
    any stopSqlLog()
         Stops CriteriaBuilder from continuing to internally log the state of SQL return CriteriaBuilder.
    any withProjections([string avg], [string count], [string countDistinct], [any distinct], [string groupProperty], [boolean id], [string max], [string min], [string property], [boolean rowCount], [string sum], [any sqlProjection], [any sqlGroupProjection], [any detachedSQLProjection])
         Setup projections for this criteria query, you can pass one or as many projection arguments as you like.
     
    Methods inherited from class WEB-INF.cftags.component
    None

    Constructor Detail

    init

    public init(string entityName, any criteria, any restrictions, any ORMService)

    Parameters:
    entityName
    criteria
    restrictions
    ORMService

    Property Detail

    SQLLoggerActive

    property boolean SQLLoggerActive = [false]

    The bit that determines if we are tracking SQL

    Attributes:
    serializable - true
    required - false

    entityName

    property string entityName

    The entity name this criteria builder is binded to

    Attributes:
    serializable - true
    required - false

    eventManager

    property any eventManager

    The system event manager

    Attributes:
    serializable - true
    required - false

    nativeCriteria

    property any nativeCriteria

    The native criteria object

    Attributes:
    serializable - true
    required - false

    Method Detail

    GETENTITYNAME

    public string GETENTITYNAME()

    get: The entity name this criteria builder is binded to


    GETEVENTMANAGER

    public any GETEVENTMANAGER()

    get: The system event manager


    GETNATIVECRITERIA

    public any GETNATIVECRITERIA()

    get: The native criteria object


    GETSQLLOGGERACTIVE

    public boolean GETSQLLOGGERACTIVE()

    get: The bit that determines if we are tracking SQL


    SETEVENTMANAGER

    public BaseBuilder SETEVENTMANAGER(any eventManager)

    set: The system event manager

    Parameters:
    eventManager

    SETSQLLOGGERACTIVE

    public BaseBuilder SETSQLLOGGERACTIVE(boolean SQLLoggerActive)

    set: The bit that determines if we are tracking SQL

    Parameters:
    SQLLoggerActive

    add

    public any add(any criterion)

    Add a restriction to constrain the results to be retrieved

    Parameters:
    criterion - A single or array of criterions to add

    addProjection

    private any addProjection([any propertyName], [any projectionType], [any projectionList])

    Parameters:
    propertyName
    projectionType
    projectionList

    canLogSql

    public boolean canLogSql()

    Returns whether or not CriteriaBuilder is currently configured to log SQL return Boolean


    convertIDValueToJavaType

    public any convertIDValueToJavaType(any id)

    Coverts an ID, list of ID's, or array of ID's values to the proper java type The method returns a coverted array of ID's

    Parameters:
    id

    convertValueToJavaType

    public any convertValueToJavaType(any propertyName, any value)

    Coverts a value to the correct javaType for the property passed in The method returns the value in the proper Java Type

    Parameters:
    propertyName
    value

    createAlias

    public any createAlias(string associationName, string alias, [numeric joinType])

    Join an association, assigning an alias to the joined association.

    Parameters:
    associationName - The name of the association property
    alias - The alias to use for this association property on restrictions
    joinType

    createCriteria

    public any createCriteria(string associationName, [numeric joinType])

    Create a new Criteria, "rooted" at the associated entity and using an Inner Join

    Parameters:
    associationName - The name of the association property to root the restrictions with
    joinType

    createRestriction

    private any createRestriction(string missingMethodName, struct missingMethodArguments)

    Parameters:
    missingMethodName
    missingMethodArguments

    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


    getSQL

    public string getSQL(boolean returnExecutableSql='false', boolean formatSql='true')

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

    Parameters:
    returnExecutableSql
    formatSql

    getSQLLog

    public array getSQLLog()

    Retrieves the SQL Log return Array


    hasProjection

    private boolean hasProjection()

    Checks whether or not a projection is currently applied to the CriteriaBuilder return Boolean


    logSQL

    public void logSQL(String label)

    Allows for one-off sql logging at any point in the process of building up CriteriaBuilder; will log the SQL state at the time of the call return void

    Parameters:
    label - {String} The label to use for the sql log record

    normalizeOrder

    private void normalizeOrder(string sortOrder, boolean ignoreCase)

    Parameters:
    sortOrder
    ignoreCase

    order

    public any order(string property, [string sortDir='asc'], [boolean ignoreCase='false'])

    Add an ordering to the result set, you can add as many as you like

    Parameters:
    property - The name of the property to order on
    sortDir
    ignoreCase - Wether to ignore case or not, defaults to false

    prepareSQLProjection

    private struct prepareSQLProjection([any rawProjection])

    Helper method to prepare sqlProjection for addition to CriteriaBuilder return Struct

    Parameters:
    rawProjection - {Struct} The raw projection configuration

    resultTransformer

    public any resultTransformer([any resultTransformer])

    Sets a valid hibernate result transformer: org.hibernate.transform.ResultTransform to use on the results

    Parameters:
    resultTransformer - a custom result transform or you can use the included ones: criteria.ALIAS_TO_ENTITY_MAP, criteria.DISTINCT_ROOT_ENTITY, criteria.PROJECTION, criteria.ROOT_ENTITY.

    setEntityName

    public any setEntityName(any entityName)

    set: The entity name this criteria builder is binded to

    Parameters:
    entityName

    setNativeCriteria

    public any setNativeCriteria(any criteria)

    set: The native criteria object

    Parameters:
    criteria

    setProjection

    public any setProjection([any projection])

    Setup a single or a projection list via native projections class: criteria.projections

    Parameters:
    projection

    startSqlLog

    public any startSqlLog(Any returnExecutableSql='false', Any formatSql='false')

    Triggers CriteriaBuilder to start internally logging the state of SQL at each iterative build return CriteriaBuilder

    Parameters:
    returnExecutableSql - {Boolean} Whether or not to return sql with query params replaced with positional values
    formatSql - {Boolean} Whether or not to run sql through formatter and wrap the sql in
     tags for more readable output

    stopSqlLog

    public any stopSqlLog()

    Stops CriteriaBuilder from continuing to internally log the state of SQL return CriteriaBuilder


    withProjections

    public any withProjections([string avg], [string count], [string countDistinct], [any distinct], [string groupProperty], [boolean id], [string max], [string min], [string property], [boolean rowCount], [string sum], [any sqlProjection], [any sqlGroupProjection], [any detachedSQLProjection])

    Setup projections for this criteria query, you can pass one or as many projection arguments as you like. The majority of the arguments take in the property name to do the projection on, which will also use that as the alias for the column or you can pass an alias after the property name separated by a : Ex: projections(avg="balance:avgBalance") The alias on the projected value can be referred to in restrictions or orderings. Please also note that the resulting array locations are done in alphabetical order of the arguments.

    Parameters:
    avg - The name of the property to avg or a list or array of property names
    count - The name of the property to count or a list or array of property names
    countDistinct - The name of the property to count distinct or a list or array of property names
    distinct - The name of the property to do a distinct on, this can be a single property name a list or an array of property names
    groupProperty - The name of the property to group by or a list or array of property names
    id - The projected identifier value
    max - The name of the property to max or a list or array of property names
    min - The name of the property to min or a list or array of property names
    property - The name of the property to do a projected value on or a list or array of property names
    rowCount - Do a row count on the criteria
    sum - The name of the property to sum or a list or array of property names
    sqlProjection - Do a projection based on arbitrary SQL string
    sqlGroupProjection - Do a projection based on arbitrary SQL string, with grouping
    detachedSQLProjection - Do a projection based on a DetachedCriteria builder config