WEB-INF.cftags.component coldbox.system.orm.hibernate.BaseORMService coldbox.system.orm.hibernate.VirtualEntityService coldbox.system.orm.hibernate.ActiveEntity
******************************************************************************* 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.
Property Summary | ||||
---|---|---|---|---|
type | property | default | serializable | required |
any
|
wirebox
WireBox entity injector, only injected if ORM entity injection is available.
|
true
|
false
|
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. |
ActiveEntity
|
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
|
populateWithPrefix([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'], string prefix)
Simple map to property population for entities with structure key prefixes. |
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 WEB-INF.cftags.component |
---|
None |
Constructor Detail |
---|
Active Entity Constructor, if you override it, make sure you call super.init()
queryCacheRegion
- The query cache region to use if not we will use one for youuseQueryCaching
- Enable query caching for this entity or not, defaults to falseeventHandling
- Enable event handling for new() and save() operations, defaults to trueuseTransactions
- Enable transactions for all major operations, defaults to truedefaultAsQuery
- What should be the default return type query or arrays for list opertions, defaults to trueProperty Detail |
---|
WireBox entity injector, only injected if ORM entity injection is available.
inject
- wireboxserializable
- truerequired
- falsepersistent
- falseMethod Detail |
---|
get: WireBox entity injector, only injected if ORM entity injection is available.
set: WireBox entity injector, only injected if ORM entity injection is available.
wirebox
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
delete
in class
BaseORMService
entity
- You can optionally pass in an entity, else this active entity is savedflush
- Flush the session or not, default is falsetransactional
- Use transactions or not, it defaults to trueEvict entity objects from session, if no arguments, then the entity evicts itself
evict
in class
VirtualEntityService
entity
- The argument can be one persistence entity or an array of entitiesGet the validation results object. This will be an empty validation object if isValid() has not being called yet.
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
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 messagesexcludeFields
- An optional list of fields to exclude from the validation.Merge an entity or array of entities back into the session
merge
in class
BaseORMService
entity
- The argument can be one persistence entity or an array of entitiesSimple map to property population for entities
populate
in class
BaseORMService
target
memento
scope
- Use scope injection instead of setter injection, no need of setters, just tell us what scope to inject totrustedSetter
- Do not check if the setter exists, just call it, great for usage with onMissingMethod() and virtual propertiesinclude
- A list of keys to include in the population ONLYexclude
- A list of keys to exclude from the populationignoreEmpty
nullEmptyInclude
nullEmptyExclude
composeRelationships
Populate from JSON, for argument definitions look at the populate method
populateFromJSON
in class
BaseORMService
target
JSONString
scope
- Use scope injection instead of setter injection, no need of setters, just tell us what scope to inject totrustedSetter
- Do not check if the setter exists, just call it, great for usage with onMissingMethod() and virtual propertiesinclude
- A list of keys to include in the population ONLYexclude
- A list of keys to exclude from the populationignoreEmpty
nullEmptyInclude
nullEmptyExclude
composeRelationships
Populate from Query, for argument definitions look at the populate method.
populateFromQuery
in class
BaseORMService
target
qry
- The query to use for populationrowNumber
scope
- Use scope injection instead of setter injection, no need of setters, just tell us what scope to inject totrustedSetter
- Do not check if the setter exists, just call it, great for usage with onMissingMethod() and virtual propertiesinclude
- A list of keys to include in the population ONLYexclude
- A list of keys to exclude from the populationignoreEmpty
nullEmptyInclude
nullEmptyExclude
composeRelationships
Populate from XML, for argument definitions look at the populate method.
populateFromXML
in class
BaseORMService
target
xml
root
- The XML root element to start fromscope
- Use scope injection instead of setter injection, no need of setters, just tell us what scope to inject totrustedSetter
- Do not check if the setter exists, just call it, great for usage with onMissingMethod() and virtual propertiesinclude
- A list of keys to include in the population ONLYexclude
- A list of keys to exclude from the populationignoreEmpty
nullEmptyInclude
nullEmptyExclude
composeRelationships
Simple map to property population for entities with structure key prefixes
populateWithPrefix
in class
BaseORMService
target
memento
scope
- Use scope injection instead of setter injection, no need of setters, just tell us what scope to inject totrustedSetter
- Do not check if the setter exists, just call it, great for usage with onMissingMethod() and virtual propertiesinclude
- A list of keys to include in the population ONLYexclude
- A list of keys to exclude from the populationignoreEmpty
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_idRefresh the state of the entity
refresh
in class
BaseORMService
entity
- The argument can be one persistence entity or an array of entitiesSave an entity using hibernate transactions or not. You can optionally flush the session also
save
in class
BaseORMService
entity
- You can optionally pass in an entity, else this active entity is savedforceInsert
- Force insert on the saveflush
- Flush the session or not, default is falsetransactional
- Use transactions or not, it defaults to true