ColdBox Platform Version 3.7.0

coldbox.system.orm.hibernate
Class ActiveEntity

WEB-INF.cftags.component
        extended by coldbox.system.orm.hibernate.BaseORMService
            extended by coldbox.system.orm.hibernate.VirtualEntityService
                extended by coldbox.system.orm.hibernate.ActiveEntity

public class ActiveEntity
extends VirtualEntityService

******************************************************************************* Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp www.coldbox.org | www.luismajano.com | www.ortussolutions.com ******************************************************************************* Description : This Active Entity object allows you to enhance your ORM entities with virtual service methods and make it follow more of an Active Record pattern, but not really :) It just allows you to operate on entity and related entity objects much much more easily. If you have enabled WireBox entity injection, then you will get an added validation features: boolean function isValid(fields="*",constraints="",locale=""){} coldbox.system.validation.result.IValidationResult function getValidationResults(){} These methods are only active if WireBox entity injection is available.


Constructor Summary
init([string queryCacheRegion], [boolean useQueryCaching], [boolean eventHandling], [boolean useTransactions], [boolean defaultAsQuery])
          Active Entity Constructor, if you override it, make sure you call super
 
Method Summary
 any GETWIREBOX()
          get: WireBox entity injector, only injected if ORM entity injection is available
 void SETWIREBOX(any wirebox)
          set: WireBox entity injector, only injected if ORM entity injection is available
 any delete([any entity], [boolean flush='false'], [boolean transactional='[runtime expression]'])
          Delete an entity
 any evict([any entity])
          Evict entity objects from session, if no arguments, then the entity evicts itself
 IValidationResult getValidationResults()
          Get the validation results object
 boolean isValid([string fields='*'], [any constraints=''], [string locale=''], [string excludeFields=''])
          Validate the ActiveEntity with the coded constraints -> this
 any merge([any entity])
          Merge an entity or array of entities back into the session
 any populate([any target='[runtime expression]'], 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='[runtime expression]'], 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='[runtime expression]'], 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='[runtime expression]'], 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 refresh([any entity])
          Refresh the state of the entity
 any save([any entity], [boolean forceInsert='false'], [boolean flush='false'], [boolean transactional='[runtime expression]'])
          Save an entity using hibernate transactions or not
 
Methods inherited from class coldbox.system.orm.hibernate.VirtualEntityService
GETDATASOURCE, GETENTITYNAME, SETDATASOURCE, SETENTITYNAME, clear, convertIDValueToJavaType, convertValueToJavaType, count, countWhere, criteriaCount, criteriaQuery, deleteAll, deleteByID, deleteByQuery, deleteWhere, executeQuery, exists, findAllWhere, findWhere, get, getAll, getKey, getPropertyNames, getSessionStatistics, getTableName, isSessionDirty, list, new, newCriteria, onMissingMethod
 
Methods inherited from class coldbox.system.orm.hibernate.BaseORMService
$delete, $deleteAll, $deleteByID, $deleteByQuery, $deleteWhere, $save, $saveAll, $transactioned, GETDEFAULTASQUERY, GETEVENTHANDLING, GETHQLDYNAMICCACHE, GETQUERYCACHEREGION, GETUSEQUERYCACHING, GETUSETRANSACTIONS, SETDEFAULTASQUERY, SETEVENTHANDLING, SETHQLDYNAMICCACHE, SETQUERYCACHEREGION, SETUSEQUERYCACHING, SETUSETRANSACTIONS, compileHQLFromDynamicMethod, createCriteriaQuery, createService, evictEntity, evictQueries, findAll, findByExample, findDynamically, findIt, getEntityGivenName, getRestrictions, saveAll, sessionContains
 
Methods inherited from class WEB-INF.cftags.component
 

Constructor Detail

init

public init([string queryCacheRegion], [boolean useQueryCaching], [boolean eventHandling], [boolean useTransactions], [boolean defaultAsQuery])
Active Entity Constructor, if you override it, make sure you call super.init()

Parameters:
queryCacheRegion - The query cache region to use if not we will use one for you
useQueryCaching - Enable query caching for this entity or not, defaults to false
eventHandling - Enable event handling for new() and save() operations, defaults to true
useTransactions - Enable transactions for all major operations, defaults to true
defaultAsQuery - What should be the default return type query or arrays for list opertions, defaults to true
Method Detail

GETWIREBOX

public any GETWIREBOX()
get: WireBox entity injector, only injected if ORM entity injection is available.


SETWIREBOX

public void SETWIREBOX(any wirebox)
set: WireBox entity injector, only injected if ORM entity injection is available.

Parameters:
wirebox

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

Overrides:
delete in class BaseORMService
Parameters:
entity - You can optionally pass in an entity, else this active entity is saved
flush - Flush the session or not, default is false
transactional - Use transactions or not, it defaults to true

evict

public any evict([any entity])
Evict entity objects from session, if no arguments, then the entity evicts itself

Overrides:
evict in class VirtualEntityService
Parameters:
entity - The argument can be one persistence entity or an array of entities

getValidationResults

public IValidationResult getValidationResults()
Get the validation results object. This will be an empty validation object if isValid() has not being called yet.


isValid

public boolean isValid([string fields='*'], [any constraints=''], [string locale=''], [string excludeFields=''])
Validate the ActiveEntity with the coded constraints -> this.constraints, or passed in shared or implicit constraints The entity must have been populated with data before the validation

Parameters:
fields - One or more fields to validate on, by default it validates all fields in the constraints. This can be a simple list or an array.
constraints - An optional shared constraints name or an actual structure of constraints to validate on.
locale - An optional locale to use for i18n messages
excludeFields - An optional list of fields to exclude from the validation.

merge

public any merge([any entity])
Merge an entity or array of entities back into the session

Overrides:
merge in class BaseORMService
Parameters:
entity - The argument can be one persistence entity or an array of entities

populate

public any populate([any target='[runtime expression]'], 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

Overrides:
populate in class BaseORMService
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='[runtime expression]'], 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

Overrides:
populateFromJSON in class BaseORMService
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='[runtime expression]'], 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.

Overrides:
populateFromQuery in class BaseORMService
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='[runtime expression]'], 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.

Overrides:
populateFromXML in class BaseORMService
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

refresh

public any refresh([any entity])
Refresh the state of the entity

Overrides:
refresh in class BaseORMService
Parameters:
entity - The argument can be one persistence entity or an array of entities

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

Overrides:
save in class BaseORMService
Parameters:
entity - You can optionally pass in an entity, else this active entity is saved
forceInsert - Force insert on the save
flush - Flush the session or not, default is false
transactional - Use transactions or not, it defaults to true

ColdBox Platform Version 3.7.0