coldbox.system.orm.hibernate

Class BaseORMService

WEB-INF.cftags.component
        extended by coldbox.system.orm.hibernate.BaseORMService
Class Attributes:
  • accessors : true
  •  
    Direct Known Subclasses:
    VirtualEntityService , ORMService
    Property Summary
    type property default serializable required
    struct HQLDynamicCache
          All calculated and parsed dynamic finders' and counters' HQL will be stored here for easier execution.

    true false
    any ORM
          The system ORM utility object.

    true false
    any ORMEventHandler
          The system ORM event handler to transmitt ORM events to.

    true false
    boolean defaultAsQuery
          The bit that determines the default return value for list(), createCriteriaQuery() and executeQuery() as query or array.

    true true false
    boolean eventHandling
          The bit that enables event handling via the ORM Event handler such as interceptions when new entities get created, etc, enabled by default.

    true true false
    string queryCacheRegion
          The queryCacheRegion name property for all query caching produced in this service.

    ORMService.defaultCache true false
    boolean useQueryCaching
          The bit that tells the service to enable query caching, disabled by default.

    false true false
    boolean useTransactions
          The bit that enables automatic hibernate transactions on all save, saveAll, update, delete methods.

    true true false
    Constructor Summary
    init([string queryCacheRegion='ORMService.defaultCache'], [boolean useQueryCaching='false'], [boolean eventHandling='true'], [boolean useTransactions='true'], [boolean defaultAsQuery='true'])
          *********************************** CONSTRUCTOR ********************************************.
    Method Summary
    private any $delete(any entity, [boolean flush='false'])
    private numeric $deleteAll(string entityName, [boolean flush='false'])
    private numeric $deleteByID(string entityName, any id, [boolean flush='false'])
    private any $deleteByQuery(string query, [any params], [numeric max='0'], [numeric offset='0'], [boolean flush='false'], [string datasource=''])
    private numeric $deleteWhere(string entityName)
    any $save(any entity, [boolean forceInsert='false'], [boolean flush='false'])
    private any $saveAll(any entities, [any forceInsert='false'], [any flush='false'])
    private any $transactioned(any method, [any argCollection='[runtime expression]'])
         My hibernate safe transaction closure wrapper.
    boolean GETDEFAULTASQUERY()
         get: The bit that determines the default return value for list(), createCriteriaQuery() and executeQuery() as query or array.
    boolean GETEVENTHANDLING()
         get: The bit that enables event handling via the ORM Event handler such as interceptions when new entities get created, etc, enabled by default.
    struct GETHQLDYNAMICCACHE()
         get: All calculated and parsed dynamic finders' and counters' HQL will be stored here for easier execution.
    any GETORM()
         get: The system ORM utility object.
    any GETORMEVENTHANDLER()
         get: The system ORM event handler to transmitt ORM events to.
    string GETQUERYCACHEREGION()
         get: The queryCacheRegion name property for all query caching produced in this service.
    boolean GETUSEQUERYCACHING()
         get: The bit that tells the service to enable query caching, disabled by default.
    boolean GETUSETRANSACTIONS()
         get: The bit that enables automatic hibernate transactions on all save, saveAll, update, delete methods.
    BaseORMService SETDEFAULTASQUERY(boolean defaultAsQuery)
         set: The bit that determines the default return value for list(), createCriteriaQuery() and executeQuery() as query or array.
    BaseORMService SETEVENTHANDLING(boolean eventHandling)
         set: The bit that enables event handling via the ORM Event handler such as interceptions when new entities get created, etc, enabled by default.
    BaseORMService SETHQLDYNAMICCACHE(struct HQLDynamicCache)
         set: All calculated and parsed dynamic finders' and counters' HQL will be stored here for easier execution.
    BaseORMService SETORM(any ORM)
         set: The system ORM utility object.
    BaseORMService SETORMEVENTHANDLER(any ORMEventHandler)
         set: The system ORM event handler to transmitt ORM events to.
    BaseORMService SETQUERYCACHEREGION(string queryCacheRegion)
         set: The queryCacheRegion name property for all query caching produced in this service.
    BaseORMService SETUSEQUERYCACHING(boolean useQueryCaching)
         set: The bit that tells the service to enable query caching, disabled by default.
    BaseORMService SETUSETRANSACTIONS(boolean useTransactions)
         set: The bit that enables automatic hibernate transactions on all save, saveAll, update, delete methods.
    any clear([string datasource='[runtime expression]'])
         Clear the session removes all the entities that are loaded or created in the session.
    private any compileHQLFromDynamicMethod([string missingMethodName], [struct missingMethodArguments], [boolean unique='true'], [boolean isCounting='false'], [struct params], [any entityName])
         Compile HQL from a dynamic method call.
    any convertIDValueToJavaType(any entityName, 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 entityName, 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.
    numeric count(string entityName, [string where=''], [any params='[runtime expression]'])
         Return the count of records in the DB for the given entity name.
    numeric countWhere(string entityName)
         Returns the count by passing name value pairs as arguments to this function.
    private any createCriteriaQuery(any entityName, [array criteria='[runtime expression]'])
         Create a new hibernate criteria object according to entityname and criterion array objects.
    any createService(string entityName, [boolean useQueryCaching='[runtime expression]'], [string queryCacheRegion='[runtime expression]'], [boolean eventHandling='[runtime expression]'])
         Create a virtual abstract service for a specfic entity.
    numeric criteriaCount(any entityName, [array criteria='[runtime expression]'])
         Get the record count using hibernate projections and criterion for specific queries.
    any criteriaQuery(any entityName, [array criteria='[runtime expression]'], [string sortOrder=''], [numeric offset='0'], [numeric max='0'], [numeric timeout='0'], [boolean ignoreCase='false'], [boolean asQuery='[runtime expression]'])
         Do a hibernate criteria based query with projections.
    any delete(any entity, [boolean flush='false'], [boolean transactional='[runtime expression]'])
         Delete an entity.
    numeric deleteAll(string entityName, [boolean flush='false'], [boolean transactional='[runtime expression]'])
         Delete all entries for an entity DLM style and transaction safe.
    numeric deleteByID(string entityName, any id, [boolean flush='false'], [boolean transactional='[runtime expression]'])
         Delete using an entity name and an incoming id, you can also flush the session if needed.
    any deleteByQuery(string query, [any params], [numeric max='0'], [numeric offset='0'], [boolean flush='false'], [boolean transactional='[runtime expression]'], [string datasource=''])
         Delete by using an HQL query and iterating via the results, it is not performing a delete query but it actually is a select query that should retrieve objects to remove Transactions are used if useTransactions bit is set or the transactional argument is passed.
    numeric deleteWhere(string entityName, [boolean transactional='[runtime expression]'])
         Deletes entities by using name value pairs as arguments to this function.
    any evict(string entityName, [string collectionName], [any id])
         Evict an entity from session, the id can be a string or structure for the primary key You can also pass in a collection name to evict from the collection.
    any evictEntity(any entities)
         Evict entity objects from session.
    any evictQueries([string cacheName], [string datasource])
         Evict all queries in the default cache or the cache region passed.
    any executeQuery(string query, [any params='[runtime expression]'], [numeric offset='0'], [numeric max='0'], [numeric timeout='0'], [boolean ignorecase='false'], [boolean asQuery='[runtime expression]'], [boolean unique='false'], [string datasource=''])
         Allows the execution of HQL queries using several nice arguments and returns either an array of entities or a query as specified by the asQuery argument.
    boolean exists(any entityName, any id)
         Checks if the given entityName and id exists in the database, this method does not load the entity into session.
    array findAll([string query], [any params='[runtime expression]'], [numeric offset='0'], [numeric max='0'], [numeric timeout='0'], [boolean ignoreCase='false'], [any example])
         Find all the entities for the specified query and params or example.
    array findAllWhere(string entityName, struct criteria, [string sortOrder=''])
         Find all entities according to criteria structure.
    any findByExample([any example], [boolean unique='false'])
         Find all/single entities by example.
    any findDynamically([string missingMethodName], [struct missingMethodArguments], [boolean unique='true'], [boolean isCounting='false'])
         A method for finding entity's dynamically, for example: findByLastNameAndFirstName('User', 'Tester', 'Test'); findByLastNameOrFirstName('User', 'Tester', 'Test') findAllByLastNameIsNotNull('User'); The first argument must be the 'entityName' or a named agument called 'entityname' Any argument which is a structure will be used as options for the query: { ignorecase, maxresults, offset, cacheable, cachename, timeout }.
    any findIt([string query], [any params='[runtime expression]'], [any example])
         Finds and returns the first result for the given query or null if no entity was found.
    any findWhere(string entityName, struct criteria)
         Find one entity (or null if not found) according to a criteria structure.
    any get(string entityName, any id, [boolean returnNew='true'])
         Get an entity using a primary key, if the id is not found this method returns null, if the id=0 or blank it returns a new entity.
    array getAll(string entityName, [any id], [string sortOrder=''])
         Retrieve all the instances from the passed in entity name using the id argument if specified The id can be a list of IDs or an array of IDs or none to retrieve all.
    any getEntityGivenName(any entity)
         Returns the entity name from a given entity object via session lookup or if new object via metadata lookup.
    any getKey(string entityName)
         Returns the key (id field) of a given entity, either simple or composite keys.
    array getPropertyNames(string entityName)
         Returns the Property Names of the entity via hibernate metadata.
    any getRestrictions()
         Get our hibernate org.
    struct getSessionStatistics([string datasource='[runtime expression]'])
         Information about the first-level (session) cache for the current session.
    string getTableName(string entityName)
         Returns the table name that the current entity string belongs to via hibernate metadata.
    boolean isSessionDirty([string datasource='[runtime expression]'])
         Checks if the session contains dirty objects that are awaiting persistence.
    any list(string entityName, [struct criteria='[runtime expression]'], [string sortOrder=''], [numeric offset='0'], [numeric max='0'], [numeric timeout='0'], [boolean ignoreCase='false'], [boolean asQuery='[runtime expression]'])
         List all of the instances of the passed in entity class name.
    any merge(any entity)
         Merge an entity or array of entities back into the session.
    any new(string entityName, [struct properties='[runtime expression]'], [boolean composeRelationships='true'], [any nullEmptyInclude=''], [any nullEmptyExclude=''], [boolean ignoreEmpty='false'], [any include=''], [any exclude=''])
         Get a new entity object by entity name and you can pass in the properties structre also to bind the entity with properties.
    any newCriteria(string entityName, [boolean useQueryCaching='false'], [string queryCacheRegion=''])
         Get a brand new criteria builder object.
    any onMissingMethod([string missingMethodName], [struct missingMethodArguments])
         A nice onMissingMethod template to create awesome dynamic methods.
    any populate(any target, struct memento, [string scope=''], [boolean trustedSetter='false'], [string include=''], [string exclude=''], [boolean ignoreEmpty='false'], [string nullEmptyInclude=''], [string nullEmptyExclude=''], [boolean composeRelationships='true'])
         Simple map to property population for entities.
    any populateFromJSON(any target, string JSONString, [string scope=''], [boolean trustedSetter='false'], [string include=''], [string exclude=''], [boolean ignoreEmpty='false'], [string nullEmptyInclude=''], [string nullEmptyExclude=''], [boolean composeRelationships='true'])
         Populate from JSON, for argument definitions look at the populate method.
    any populateFromQuery(any target, any qry, [numeric rowNumber='1'], [string scope=''], [boolean trustedSetter='false'], [string include=''], [string exclude=''], [boolean ignoreEmpty='false'], [string nullEmptyInclude=''], [string nullEmptyExclude=''], [boolean composeRelationships='true'])
         Populate from Query, for argument definitions look at the populate method.
    any populateFromXML(any target, string xml, [string root=''], [string scope=''], [boolean trustedSetter='false'], [string include=''], [string exclude=''], [boolean ignoreEmpty='false'], [string nullEmptyInclude=''], [string nullEmptyExclude=''], [boolean composeRelationships='true'])
         Populate from XML, for argument definitions look at the populate method.
    any populateWithPrefix(any target, struct memento, [string scope=''], [boolean trustedSetter='false'], [string include=''], [string exclude=''], [boolean ignoreEmpty='false'], [string nullEmptyInclude=''], [string nullEmptyExclude=''], [boolean composeRelationships='true'], string prefix)
         Simple map to property population for entities with structure key prefixes.
    any refresh(any entity)
         Refresh the state of an entity or array of entities from the database.
    any save(any entity, [boolean forceInsert='false'], [boolean flush='false'], [boolean transactional='[runtime expression]'])
         Save an entity using hibernate transactions or not.
    any saveAll(any entities, [any forceInsert='false'], [any flush='false'], [boolean transactional='[runtime expression]'])
         Saves an array of passed entities in specified order Transactions are used if useTransactions bit is set or the transactional argument is passed.
    boolean sessionContains(any entity)
         Checks if the current session contains the passed in entity.
     
    Methods inherited from class WEB-INF.cftags.component
    None

    Constructor Detail

    init

    public init([string queryCacheRegion='ORMService.defaultCache'], [boolean useQueryCaching='false'], [boolean eventHandling='true'], [boolean useTransactions='true'], [boolean defaultAsQuery='true'])

    *********************************** CONSTRUCTOR ********************************************

    Parameters:
    queryCacheRegion
    useQueryCaching
    eventHandling
    useTransactions
    defaultAsQuery

    Property Detail

    HQLDynamicCache

    property struct HQLDynamicCache

    All calculated and parsed dynamic finders' and counters' HQL will be stored here for easier execution

    Attributes:
    serializable - true
    required - false

    ORM

    property any ORM

    The system ORM utility object

    Attributes:
    serializable - true
    required - false

    ORMEventHandler

    property any ORMEventHandler

    The system ORM event handler to transmitt ORM events to

    Attributes:
    serializable - true
    required - false

    defaultAsQuery

    property boolean defaultAsQuery = [true]

    The bit that determines the default return value for list(), createCriteriaQuery() and executeQuery() as query or array

    Attributes:
    serializable - true
    required - false

    eventHandling

    property boolean eventHandling = [true]

    The bit that enables event handling via the ORM Event handler such as interceptions when new entities get created, etc, enabled by default.

    Attributes:
    serializable - true
    required - false

    queryCacheRegion

    property string queryCacheRegion = [ORMService.defaultCache]

    The queryCacheRegion name property for all query caching produced in this service

    Attributes:
    serializable - true
    required - false

    useQueryCaching

    property boolean useQueryCaching = [false]

    The bit that tells the service to enable query caching, disabled by default

    Attributes:
    serializable - true
    required - false

    useTransactions

    property boolean useTransactions = [true]

    The bit that enables automatic hibernate transactions on all save, saveAll, update, delete methods

    Attributes:
    serializable - true
    required - false

    Method Detail

    $delete

    private any $delete(any entity, [boolean flush='false'])

    Parameters:
    entity
    flush

    $deleteAll

    private numeric $deleteAll(string entityName, [boolean flush='false'])

    Parameters:
    entityName
    flush

    $deleteByID

    private numeric $deleteByID(string entityName, any id, [boolean flush='false'])

    Parameters:
    entityName
    id
    flush

    $deleteByQuery

    private any $deleteByQuery(string query, [any params], [numeric max='0'], [numeric offset='0'], [boolean flush='false'], [string datasource=''])

    Parameters:
    query
    params
    max
    offset
    flush
    datasource

    $deleteWhere

    private numeric $deleteWhere(string entityName)

    Parameters:
    entityName

    $save

    public any $save(any entity, [boolean forceInsert='false'], [boolean flush='false'])

    Parameters:
    entity
    forceInsert
    flush

    $saveAll

    private any $saveAll(any entities, [any forceInsert='false'], [any flush='false'])

    Parameters:
    entities
    forceInsert
    flush

    $transactioned

    private any $transactioned(any method, [any argCollection='[runtime expression]'])

    My hibernate safe transaction closure wrapper

    Parameters:
    method - the method to closure
    argCollection - the arguments to passthrough

    GETDEFAULTASQUERY

    public boolean GETDEFAULTASQUERY()

    get: The bit that determines the default return value for list(), createCriteriaQuery() and executeQuery() as query or array


    GETEVENTHANDLING

    public boolean GETEVENTHANDLING()

    get: The bit that enables event handling via the ORM Event handler such as interceptions when new entities get created, etc, enabled by default.


    GETHQLDYNAMICCACHE

    public struct GETHQLDYNAMICCACHE()

    get: All calculated and parsed dynamic finders' and counters' HQL will be stored here for easier execution


    GETORM

    public any GETORM()

    get: The system ORM utility object


    GETORMEVENTHANDLER

    public any GETORMEVENTHANDLER()

    get: The system ORM event handler to transmitt ORM events to


    GETQUERYCACHEREGION

    public string GETQUERYCACHEREGION()

    get: The queryCacheRegion name property for all query caching produced in this service


    GETUSEQUERYCACHING

    public boolean GETUSEQUERYCACHING()

    get: The bit that tells the service to enable query caching, disabled by default


    GETUSETRANSACTIONS

    public boolean GETUSETRANSACTIONS()

    get: The bit that enables automatic hibernate transactions on all save, saveAll, update, delete methods


    SETDEFAULTASQUERY

    public BaseORMService SETDEFAULTASQUERY(boolean defaultAsQuery)

    set: The bit that determines the default return value for list(), createCriteriaQuery() and executeQuery() as query or array

    Parameters:
    defaultAsQuery

    SETEVENTHANDLING

    public BaseORMService SETEVENTHANDLING(boolean eventHandling)

    set: The bit that enables event handling via the ORM Event handler such as interceptions when new entities get created, etc, enabled by default.

    Parameters:
    eventHandling

    SETHQLDYNAMICCACHE

    public BaseORMService SETHQLDYNAMICCACHE(struct HQLDynamicCache)

    set: All calculated and parsed dynamic finders' and counters' HQL will be stored here for easier execution

    Parameters:
    HQLDynamicCache

    SETORM

    public BaseORMService SETORM(any ORM)

    set: The system ORM utility object

    Parameters:
    ORM

    SETORMEVENTHANDLER

    public BaseORMService SETORMEVENTHANDLER(any ORMEventHandler)

    set: The system ORM event handler to transmitt ORM events to

    Parameters:
    ORMEventHandler

    SETQUERYCACHEREGION

    public BaseORMService SETQUERYCACHEREGION(string queryCacheRegion)

    set: The queryCacheRegion name property for all query caching produced in this service

    Parameters:
    queryCacheRegion

    SETUSEQUERYCACHING

    public BaseORMService SETUSEQUERYCACHING(boolean useQueryCaching)

    set: The bit that tells the service to enable query caching, disabled by default

    Parameters:
    useQueryCaching

    SETUSETRANSACTIONS

    public BaseORMService SETUSETRANSACTIONS(boolean useTransactions)

    set: The bit that enables automatic hibernate transactions on all save, saveAll, update, delete methods

    Parameters:
    useTransactions

    clear

    public any clear([string datasource='[runtime expression]'])

    Clear the session removes all the entities that are loaded or created in the session. This clears the first level cache and removes the objects that are not yet saved to the database.

    Parameters:
    datasource

    compileHQLFromDynamicMethod

    private any compileHQLFromDynamicMethod([string missingMethodName], [struct missingMethodArguments], [boolean unique='true'], [boolean isCounting='false'], [struct params], [any entityName])

    Compile HQL from a dynamic method call

    Parameters:
    missingMethodName
    missingMethodArguments
    unique
    isCounting
    params
    entityName

    convertIDValueToJavaType

    public any convertIDValueToJavaType(any entityName, 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:
    entityName
    id

    convertValueToJavaType

    public any convertValueToJavaType(any entityName, 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:
    entityName
    propertyName
    value

    count

    public numeric count(string entityName, [string where=''], [any params='[runtime expression]'])

    Return the count of records in the DB for the given entity name. You can also pass an optional where statement that can filter the count. Ex: count('User','age > 40 AND name="joe"'). You can even use params with this method: Ex: count('User','age > ? AND name = ?',[40,"joe"])

    Parameters:
    entityName
    where
    params

    countWhere

    public numeric countWhere(string entityName)

    Returns the count by passing name value pairs as arguments to this function. One mandatory argument is to pass the 'entityName'. The rest of the arguments are used in the where class using AND notation and parameterized. Ex: countWhere(entityName="User",age="20");

    Parameters:
    entityName

    createCriteriaQuery

    private any createCriteriaQuery(any entityName, [array criteria='[runtime expression]'])

    Create a new hibernate criteria object according to entityname and criterion array objects

    Parameters:
    entityName
    criteria

    createService

    public any createService(string entityName, [boolean useQueryCaching='[runtime expression]'], [string queryCacheRegion='[runtime expression]'], [boolean eventHandling='[runtime expression]'])

    Create a virtual abstract service for a specfic entity.

    Parameters:
    entityName
    useQueryCaching
    queryCacheRegion
    eventHandling

    criteriaCount

    public numeric criteriaCount(any entityName, [array criteria='[runtime expression]'])

    Get the record count using hibernate projections and criterion for specific queries

    Parameters:
    entityName
    criteria

    criteriaQuery

    public any criteriaQuery(any entityName, [array criteria='[runtime expression]'], [string sortOrder=''], [numeric offset='0'], [numeric max='0'], [numeric timeout='0'], [boolean ignoreCase='false'], [boolean asQuery='[runtime expression]'])

    Do a hibernate criteria based query with projections. You must pass an array of criterion objects by using the Hibernate Restrictions object that can be retrieved from this service using ''getRestrictions()''. The Criteria interface allows to create and execute object-oriented queries. It is powerful alternative to the HQL but has own limitations. Criteria Query is used mostly in case of multi criteria search screens, where HQL is not very effective.

    Parameters:
    entityName
    criteria
    sortOrder
    offset
    max
    timeout
    ignoreCase
    asQuery

    delete

    public any delete(any entity, [boolean flush='false'], [boolean transactional='[runtime expression]'])

    Delete an entity. The entity argument can be a single entity or an array of entities. You can optionally flush the session also after committing Transactions are used if useTransactions bit is set or the transactional argument is passed

    Parameters:
    entity
    flush
    transactional

    deleteAll

    public numeric deleteAll(string entityName, [boolean flush='false'], [boolean transactional='[runtime expression]'])

    Delete all entries for an entity DLM style and transaction safe. It also returns all the count of deletions Transactions are used if useTransactions bit is set or the transactional argument is passed

    Parameters:
    entityName
    flush
    transactional

    deleteByID

    public numeric deleteByID(string entityName, any id, [boolean flush='false'], [boolean transactional='[runtime expression]'])

    Delete using an entity name and an incoming id, you can also flush the session if needed. The id parameter can be a single id or an array of IDs to delete The method returns the count of deleted entities. Transactions are used if useTransactions bit is set or the transactional argument is passed

    Parameters:
    entityName
    id
    flush
    transactional

    deleteByQuery

    public any deleteByQuery(string query, [any params], [numeric max='0'], [numeric offset='0'], [boolean flush='false'], [boolean transactional='[runtime expression]'], [string datasource=''])

    Delete by using an HQL query and iterating via the results, it is not performing a delete query but it actually is a select query that should retrieve objects to remove Transactions are used if useTransactions bit is set or the transactional argument is passed

    Parameters:
    query
    params
    max
    offset
    flush
    transactional
    datasource

    deleteWhere

    public numeric deleteWhere(string entityName, [boolean transactional='[runtime expression]'])

    Deletes entities by using name value pairs as arguments to this function. One mandatory argument is to pass the 'entityName'. The rest of the arguments are used in the where class using AND notation and parameterized. Ex: deleteWhere(entityName="User",age="4",isActive=true); Transactions are used if useTransactions bit is set or the transactional argument is passed

    Parameters:
    entityName
    transactional

    evict

    public any evict(string entityName, [string collectionName], [any id])

    Evict an entity from session, the id can be a string or structure for the primary key You can also pass in a collection name to evict from the collection

    Parameters:
    entityName
    collectionName
    id

    evictEntity

    public any evictEntity(any entities)

    Evict entity objects from session.

    Parameters:
    entities - The argument can be one persistence entity or an array of entities

    evictQueries

    public any evictQueries([string cacheName], [string datasource])

    Evict all queries in the default cache or the cache region passed

    Parameters:
    cacheName
    datasource

    executeQuery

    public any executeQuery(string query, [any params='[runtime expression]'], [numeric offset='0'], [numeric max='0'], [numeric timeout='0'], [boolean ignorecase='false'], [boolean asQuery='[runtime expression]'], [boolean unique='false'], [string datasource=''])

    Allows the execution of HQL queries using several nice arguments and returns either an array of entities or a query as specified by the asQuery argument. The params filtering can be using named or positional.

    Parameters:
    query
    params
    offset
    max
    timeout
    ignorecase
    asQuery
    unique
    datasource

    exists

    public boolean exists(any entityName, any id)

    Checks if the given entityName and id exists in the database, this method does not load the entity into session

    Parameters:
    entityName
    id

    findAll

    public array findAll([string query], [any params='[runtime expression]'], [numeric offset='0'], [numeric max='0'], [numeric timeout='0'], [boolean ignoreCase='false'], [any example])

    Find all the entities for the specified query and params or example

    Parameters:
    query
    params
    offset
    max
    timeout
    ignoreCase
    example

    findAllWhere

    public array findAllWhere(string entityName, struct criteria, [string sortOrder=''])

    Find all entities according to criteria structure

    Parameters:
    entityName
    criteria
    sortOrder

    findByExample

    public any findByExample([any example], [boolean unique='false'])

    Find all/single entities by example

    Parameters:
    example
    unique

    findDynamically

    public any findDynamically([string missingMethodName], [struct missingMethodArguments], [boolean unique='true'], [boolean isCounting='false'])

    A method for finding entity's dynamically, for example: findByLastNameAndFirstName('User', 'Tester', 'Test'); findByLastNameOrFirstName('User', 'Tester', 'Test') findAllByLastNameIsNotNull('User'); The first argument must be the 'entityName' or a named agument called 'entityname' Any argument which is a structure will be used as options for the query: { ignorecase, maxresults, offset, cacheable, cachename, timeout }

    Parameters:
    missingMethodName
    missingMethodArguments
    unique
    isCounting

    findIt

    public any findIt([string query], [any params='[runtime expression]'], [any example])

    Finds and returns the first result for the given query or null if no entity was found. You can either use the query and params combination or send in an example entity to find.

    Parameters:
    query
    params
    example - DEPRECATED. Use findByExample() instead, deprecated by 3.5

    findWhere

    public any findWhere(string entityName, struct criteria)

    Find one entity (or null if not found) according to a criteria structure

    Parameters:
    entityName
    criteria

    get

    public any get(string entityName, any id, [boolean returnNew='true'])

    Get an entity using a primary key, if the id is not found this method returns null, if the id=0 or blank it returns a new entity.

    Parameters:
    entityName - the name of the entity to retrieve
    id - An optional primary key to use to retrieve the entity, if the id is 0 or empty
    returnNew

    getAll

    public array getAll(string entityName, [any id], [string sortOrder=''])

    Retrieve all the instances from the passed in entity name using the id argument if specified The id can be a list of IDs or an array of IDs or none to retrieve all.

    Parameters:
    entityName
    id
    sortOrder

    getEntityGivenName

    public any getEntityGivenName(any entity)

    Returns the entity name from a given entity object via session lookup or if new object via metadata lookup

    Parameters:
    entity

    getKey

    public any getKey(string entityName)

    Returns the key (id field) of a given entity, either simple or composite keys. If the key is a simple pk then it will return a string, if it is a composite key then it returns an array

    Parameters:
    entityName

    getPropertyNames

    public array getPropertyNames(string entityName)

    Returns the Property Names of the entity via hibernate metadata

    Parameters:
    entityName

    getRestrictions

    public any getRestrictions()

    Get our hibernate org.hibernate.criterion.Restrictions proxy object


    getSessionStatistics

    public struct getSessionStatistics([string datasource='[runtime expression]'])

    Information about the first-level (session) cache for the current session

    Parameters:
    datasource

    getTableName

    public string getTableName(string entityName)

    Returns the table name that the current entity string belongs to via hibernate metadata

    Parameters:
    entityName

    isSessionDirty

    public boolean isSessionDirty([string datasource='[runtime expression]'])

    Checks if the session contains dirty objects that are awaiting persistence

    Parameters:
    datasource

    list

    public any list(string entityName, [struct criteria='[runtime expression]'], [string sortOrder=''], [numeric offset='0'], [numeric max='0'], [numeric timeout='0'], [boolean ignoreCase='false'], [boolean asQuery='[runtime expression]'])

    List all of the instances of the passed in entity class name. You can pass in several optional arguments like a struct of filtering criteria, a sortOrder string, offset, max, ignorecase, and timeout. Caching for the list is based on the useQueryCaching class property and the cachename property is based on the queryCacheRegion class property.

    Parameters:
    entityName
    criteria
    sortOrder
    offset
    max
    timeout
    ignoreCase
    asQuery

    merge

    public any merge(any entity)

    Merge an entity or array of entities back into the session

    Parameters:
    entity

    new

    public any new(string entityName, [struct properties='[runtime expression]'], [boolean composeRelationships='true'], [any nullEmptyInclude=''], [any nullEmptyExclude=''], [boolean ignoreEmpty='false'], [any include=''], [any exclude=''])

    Get a new entity object by entity name and you can pass in the properties structre also to bind the entity with properties

    Parameters:
    entityName - The entity to create
    properties - The structure of data to populate the entity with. By default we will inspect for many-to-one, one-to-many and many-to-many relationships and compose them for you.
    composeRelationships - Automatically attempt to compose relationships from the incoming properties memento
    nullEmptyInclude - A list of keys to NULL when empty
    nullEmptyExclude - A list of keys to NOT NULL when empty
    ignoreEmpty - Ignore empty values on populations, great for ORM population
    include - A list of keys to include in the population from the incoming properties memento
    exclude - A list of keys to exclude in the population from the incoming properties memento

    newCriteria

    public any newCriteria(string entityName, [boolean useQueryCaching='false'], [string queryCacheRegion=''])

    Get a brand new criteria builder object

    Parameters:
    entityName - The name of the entity to bind this criteria query to
    useQueryCaching - Activate query caching for the list operations
    queryCacheRegion - The query cache region to use, which defaults to criterias.{entityName}

    onMissingMethod

    public any onMissingMethod([string missingMethodName], [struct missingMethodArguments])

    A nice onMissingMethod template to create awesome dynamic methods.

    Parameters:
    missingMethodName
    missingMethodArguments

    populate

    public any populate(any target, struct memento, [string scope=''], [boolean trustedSetter='false'], [string include=''], [string exclude=''], [boolean ignoreEmpty='false'], [string nullEmptyInclude=''], [string nullEmptyExclude=''], [boolean composeRelationships='true'])

    Simple map to property population for entities

    Parameters:
    target
    memento
    scope - Use scope injection instead of setter injection, no need of setters, just tell us what scope to inject to
    trustedSetter - Do not check if the setter exists, just call it, great for usage with onMissingMethod() and virtual properties
    include - A list of keys to include in the population ONLY
    exclude - A list of keys to exclude from the population
    ignoreEmpty
    nullEmptyInclude
    nullEmptyExclude
    composeRelationships

    populateFromJSON

    public any populateFromJSON(any target, string JSONString, [string scope=''], [boolean trustedSetter='false'], [string include=''], [string exclude=''], [boolean ignoreEmpty='false'], [string nullEmptyInclude=''], [string nullEmptyExclude=''], [boolean composeRelationships='true'])

    Populate from JSON, for argument definitions look at the populate method

    Parameters:
    target
    JSONString
    scope - Use scope injection instead of setter injection, no need of setters, just tell us what scope to inject to
    trustedSetter - Do not check if the setter exists, just call it, great for usage with onMissingMethod() and virtual properties
    include - A list of keys to include in the population ONLY
    exclude - A list of keys to exclude from the population
    ignoreEmpty
    nullEmptyInclude
    nullEmptyExclude
    composeRelationships

    populateFromQuery

    public any populateFromQuery(any target, any qry, [numeric rowNumber='1'], [string scope=''], [boolean trustedSetter='false'], [string include=''], [string exclude=''], [boolean ignoreEmpty='false'], [string nullEmptyInclude=''], [string nullEmptyExclude=''], [boolean composeRelationships='true'])

    Populate from Query, for argument definitions look at the populate method

    Parameters:
    target
    qry - The query to use for population
    rowNumber
    scope - Use scope injection instead of setter injection, no need of setters, just tell us what scope to inject to
    trustedSetter - Do not check if the setter exists, just call it, great for usage with onMissingMethod() and virtual properties
    include - A list of keys to include in the population ONLY
    exclude - A list of keys to exclude from the population
    ignoreEmpty
    nullEmptyInclude
    nullEmptyExclude
    composeRelationships

    populateFromXML

    public any populateFromXML(any target, string xml, [string root=''], [string scope=''], [boolean trustedSetter='false'], [string include=''], [string exclude=''], [boolean ignoreEmpty='false'], [string nullEmptyInclude=''], [string nullEmptyExclude=''], [boolean composeRelationships='true'])

    Populate from XML, for argument definitions look at the populate method

    Parameters:
    target
    xml
    root - The XML root element to start from
    scope - Use scope injection instead of setter injection, no need of setters, just tell us what scope to inject to
    trustedSetter - Do not check if the setter exists, just call it, great for usage with onMissingMethod() and virtual properties
    include - A list of keys to include in the population ONLY
    exclude - A list of keys to exclude from the population
    ignoreEmpty
    nullEmptyInclude
    nullEmptyExclude
    composeRelationships

    populateWithPrefix

    public any populateWithPrefix(any target, struct memento, [string scope=''], [boolean trustedSetter='false'], [string include=''], [string exclude=''], [boolean ignoreEmpty='false'], [string nullEmptyInclude=''], [string nullEmptyExclude=''], [boolean composeRelationships='true'], string prefix)

    Simple map to property population for entities with structure key prefixes

    Parameters:
    target
    memento
    scope - Use scope injection instead of setter injection, no need of setters, just tell us what scope to inject to
    trustedSetter - Do not check if the setter exists, just call it, great for usage with onMissingMethod() and virtual properties
    include - A list of keys to include in the population ONLY
    exclude - A list of keys to exclude from the population
    ignoreEmpty
    nullEmptyInclude
    nullEmptyExclude
    composeRelationships
    prefix - The prefix used to filter, Example: 'user' would apply to the following formfield: 'user_id' and 'user_name' but not 'address_id

    refresh

    public any refresh(any entity)

    Refresh the state of an entity or array of entities from the database

    Parameters:
    entity

    save

    public any save(any entity, [boolean forceInsert='false'], [boolean flush='false'], [boolean transactional='[runtime expression]'])

    Save an entity using hibernate transactions or not. You can optionally flush the session also

    Parameters:
    entity
    forceInsert
    flush
    transactional

    saveAll

    public any saveAll(any entities, [any forceInsert='false'], [any flush='false'], [boolean transactional='[runtime expression]'])

    Saves an array of passed entities in specified order Transactions are used if useTransactions bit is set or the transactional argument is passed

    Parameters:
    entities - An array of entities to save
    forceInsert
    flush
    transactional

    sessionContains

    public boolean sessionContains(any entity)

    Checks if the current session contains the passed in entity

    Parameters:
    entity