lucee.Component
cborm.BaseORMService
| Property Summary | ||||
|---|---|---|---|---|
| type | property | default | serializable | required |
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
|
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
|
|
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. |
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. |
any
|
convertValueToJavaType(any entityName, any propertyName, any value)
Coverts a value to the correct javaType for the property passed in. |
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. |
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. |
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:. |
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. |
string
|
getDefaultAsQuery()
|
any
|
getEntityGivenName(any entity)
Returns the entity name from a given entity object via session lookup or if new object via metadata lookup. |
string
|
getEventHandling()
|
string
|
getHQLDynamicCache()
|
any
|
getKey(string entityName)
Returns the key (id field) of a given entity, either simple or composite keys. |
string
|
getORM()
|
string
|
getORMEventHandler()
|
array
|
getPropertyNames(string entityName)
Returns the Property Names of the entity via hibernate metadata. |
string
|
getQueryCacheRegion()
|
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. |
string
|
getUseQueryCaching()
|
string
|
getUseTransactions()
|
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 a 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. |
boolean
|
sessionContains(any entity)
Checks if the current session contains the passed in entity. |
any
|
setDefaultAsQuery(boolean defaultAsQuery)
|
any
|
setEventHandling(boolean eventHandling)
|
any
|
setHQLDynamicCache(struct HQLDynamicCache)
|
any
|
setORM(any ORM)
|
any
|
setORMEventHandler(any ORMEventHandler)
|
any
|
setQueryCacheRegion(string queryCacheRegion)
|
any
|
setUseQueryCaching(boolean useQueryCaching)
|
any
|
setUseTransactions(boolean useTransactions)
|
| Methods inherited from class lucee.Component |
|---|
| None |
| Constructor Detail |
|---|
Constructor
queryCacheRegion - The default query cache region to use, by default it uses ORMService.defaultCacheuseQueryCaching - Activate caching or noteventHandling - Activate event handling or notuseTransactions - Use cftransactions around all crud operations or notdefaultAsQuery - Return queries or array of objects by default| Property Detail |
|---|
The bit that determines the default return value for list(), createCriteriaQuery() and executeQuery() as query or array
access - publicrequired - falsereturntype - anypersistent - falseserializable - trueThe bit that enables event handling via the ORM Event handler such as interceptions when new entities get created, etc, enabled by default.
access - publicrequired - falsereturntype - anypersistent - falseserializable - trueAll calculated and parsed dynamic finders' and counters' HQL will be stored here for easier execution
access - publicrequired - falsereturntype - anypersistent - falseserializable - trueThe system ORM utility object
access - publicrequired - falsereturntype - anypersistent - falseserializable - trueThe system ORM event handler to transmitt ORM events to
access - publicrequired - falsereturntype - anypersistent - falseserializable - trueThe queryCacheRegion name property for all query caching produced in this service
access - publicrequired - falsereturntype - anypersistent - falseserializable - trueThe bit that tells the service to enable query caching, disabled by default
access - publicrequired - falsereturntype - anypersistent - falseserializable - trueThe bit that enables automatic hibernate transactions on all save, saveAll, update, delete methods
access - publicrequired - falsereturntype - anypersistent - falseserializable - true| Method Detail |
|---|
entityflushentityNameflushentityNameidflushqueryparamsmaxoffsetflushdatasourceentityNameentityforceInsertflushentitiesforceInsertflushMy hibernate safe transaction closure wrapper
method - the method to closureargCollection - the arguments to passthroughClear 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.
datasourceCompile HQL from a dynamic method call
missingMethodNamemissingMethodArgumentsuniqueisCountingparamsentityNameCoverts 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
entityNameidCoverts a value to the correct javaType for the property passed in The method returns the value in the proper Java Type
entityNamepropertyNamevalueReturn 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"])
entityNamewhereparamsReturns 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");
entityNameCreate a new hibernate criteria object according to entityname and criterion array objects
entityNamecriteriaCreate a virtual abstract service for a specfic entity
entityName - The name of the entity to bind the virtual service touseQueryCaching - Activate caching or notqueryCacheRegion - The default query cache region to use, by default it uses ORMService.defaultCacheeventHandling - Activate event handling or notGet the record count using hibernate projections and criterion for specific queries
entityNamecriteriaDo 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.
entityNamecriteriasortOrderoffsetmaxtimeoutignoreCaseasQueryDelete 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
entityflushtransactionalDelete 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
entityNameflushtransactionalDelete 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
entityNameidflushtransactionalDelete 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
queryparamsmaxoffsetflushtransactionaldatasourceDeletes 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
entityNametransactionalEvict 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
entityNamecollectionNameidEvict entity objects from session.
entities - The argument can be one persistence entity or an array of entitiesEvict all queries in the default cache or the cache region passed
cacheNamedatasourceAllows 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.
queryparamsoffsetmaxtimeoutignorecaseasQueryuniquedatasourceChecks if the given entityName and id exists in the database, this method does not load the entity into session
entityNameidFind all the entities for the specified query and params or example
queryparamsoffsetmaxtimeoutignoreCaseexample - DEPRECATED use findByExample() this will be dropped in 3.5Find all entities according to criteria structure
entityNamecriteriasortOrderFind all/single entities by example
exampleuniqueA 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 }
missingMethodNamemissingMethodArgumentsuniqueisCountingFinds 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.
queryparamsexample - DEPRECATED. Use findByExample() instead, deprecated by 3.5Find one entity (or null if not found) according to a criteria structure
entityNamecriteriaGet 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.
entityName - the name of the entity to retrieveid - An optional primary key to use to retrieve the entity, if the id is 0 or emptyreturnNewRetrieve 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.
entityNameidsortOrderReturns the entity name from a given entity object via session lookup or if new object via metadata lookup
entityReturns 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
entityNameReturns the Property Names of the entity via hibernate metadata
entityNameGet our hibernate org.hibernate.criterion.Restrictions proxy object
Information about the first-level (session) cache for the current session
datasourceReturns the table name that the current entity string belongs to via hibernate metadata
entityNameChecks if the session contains dirty objects that are awaiting persistence
datasourceList 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.
entityNamecriteriasortOrderoffsetmaxtimeoutignoreCaseasQueryMerge an entity or array of entities back into a session
entity - A single or an array of entities to re-mergeGet a new entity object by entity name and you can pass in the properties structre also to bind the entity with properties
entityName - The entity to createproperties - 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 mementonullEmptyInclude - A list of keys to NULL when emptynullEmptyExclude - A list of keys to NOT NULL when emptyignoreEmpty - Ignore empty values on populations, great for ORM populationinclude - A list of keys to include in the population from the incoming properties mementoexclude - A list of keys to exclude in the population from the incoming properties mementoGet a brand new criteria builder object
entityName - The name of the entity to bind this criteria query touseQueryCaching - Activate query caching for the list operationsqueryCacheRegion - The query cache region to use, which defaults to criterias.{entityName}A nice onMissingMethod template to create awesome dynamic methods.
missingMethodNamemissingMethodArgumentsSimple map to property population for entities
targetmemento - The map/struct to populate the entity withscope - 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 populationignoreEmptynullEmptyIncludenullEmptyExcludecomposeRelationshipsPopulate from JSON, for argument definitions look at the populate method
targetJSONString - The JSON packet to use for populationscope - 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 populationignoreEmptynullEmptyIncludenullEmptyExcludecomposeRelationshipsPopulate from Query, for argument definitions look at the populate method
targetqry - The query to use for populationrowNumber - The row number to use for populationscope - 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 populationignoreEmptynullEmptyIncludenullEmptyExcludecomposeRelationshipsPopulate from XML, for argument definitions look at the populate method
targetxml - The XML string or packet or XML object to populate fromroot - 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 populationignoreEmptynullEmptyIncludenullEmptyExcludecomposeRelationshipsSimple map to property population for entities with structure key prefixes
targetmemento - The map/struct to populate the entity withscope - 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 populationignoreEmptynullEmptyIncludenullEmptyExcludecomposeRelationshipsprefix - The prefix used to filter, Example: 'user' would apply to the following formfield: 'user_id' and 'user_name' but not 'address_id'Refresh the state of an entity or array of entities from the database
entitySave an entity using hibernate transactions or not. You can optionally flush the session also
entityforceInsertflushtransactionalSaves an array of passed entities in specified order Transactions are used if useTransactions bit is set or the transactional argument is passed
entities - An array of entities to saveforceInsertflushtransactionalChecks if the current session contains the passed in entity
entitydefaultAsQueryeventHandlingHQLDynamicCacheORMORMEventHandlerqueryCacheRegionuseQueryCachinguseTransactions