Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
These methods allows you to tap into the Criteria Queries API so you can do fluent and functional queries with your ORM objects.
The Base ORM Service has a ton of methods to assist you with your ORM needs. We have compiled them under this section under several different categories:
Criteria Queries
Creation - Population
Counters
Deleting Entities
Entity Convenience
Finders
Getters
ORM Session
Querying
Saving
Utility
Like always, you can find the latest API Docs in the link below:
Get our hibernate org.hibernate.criterion.Restrictions
proxy object that will help you produce criterias.
This function returns an instance of cborm.models.criterion.Restrictions
Adobe ColdFusion will throw an "Invalid CFML construct" for certain CBORM methods that match reserved operator names, such as .and()
, .or()
, and .eq()
. To avoid these errors and build cross-engine compatible code, use .$and()
, .$or()
, and .isEq()
.
These methods allow you to create entities and populate them from external data like structures, json, xml, queries and much more.
Get a new entity object by entity name. You can also pass in a structure called properties
that will be used to populate the new entity with or you can use optional named parameters to call setters within the new entity to have shorthand population.
This function returns the newly created entity
Key | Type | Required | Default | Description |
entityName | any | true | --- |
properties | struct | false | {} | A structure of name-value pairs to populate the new entity with |
composeRelationships | boolean | false | true | Automatically attempt to compose relationships from the incoming properties memento |
nullEmptyInclude | string | false | --- | A list of keys to NULL when empty |
nullEmptyExclude | string | false | --- | A list of keys to NOT NULL when empty |
ignoreEmpty | boolean | false | false | Ignore empty property values on populations |
include | string | false | --- | A list of keys to include in the population from the incoming properties memento |
exclude | string | false | --- | A list of keys to exclude in the population from the incoming properties memento |
Populate an entity with a structure of name-value pairs. Make sure the names of the properties match the keys in the structure.
This function returns the populated object
INFO With composeRelationships=true, you can populate one-to-many, many-to-one, many-to-many, and one-to-one relationships from property values in the memento. For 'many-to-one' and 'one-to-one' relationships, the value of the property in the memento should be a single value of the primary key of the target entity to be loaded. For 'one-to-many' and 'many-to-many' relationships, the value of the property in the memento should a comma-delimited list or array of the primary keys of the target entities to be loaded.
Key
Type
Required
Default
Description
target
any
Yes
---
The entity to populate
memento
struct
Yes
---
The structure of name-value pairs to try to populate the entity with
scope
string
No
Use scope injection instead of setter injection, no need of setters, just tell us what scope to inject to
trustedSetter
Boolean
No
false
Do not check if the setter exists, just call it, great for usage with onMissingMethod() and virtual properties
include
string
No
A list of keys to ONLY include in the population
exclude
string
No
A list of keys to exclude from the population
nullEmptyInclude
string
No
A list of keys to NULL when empty, specifically for ORM population. You can also specify "*" for all fields
nullEmptyExclude
string
No
A list of keys to NOT NULL when empty, specifically for ORM population. You can also specify "*" for all fields
composeRelationships
boolean
No
true
When true, will automatically attempt to compose relationships from memento
Key | Type | Required | Default | Description |
target | any | Yes | --- | The entity to populate |
JSONString | string | Yes | --- | The JSON packet to use for population |
scope | string | No | Use scope injection instead of setter injection, no need of setters, just tell us what scope to inject to |
trustedSetter | Boolean | No | false | Do not check if the setter exists, just call it, great for usage with onMissingMethod() and virtual properties |
include | string | No | A list of keys to ONLY include in the population |
exclude | string | No | A list of keys to exclude from the population |
nullEmptyInclude | string | No | A list of keys to NULL when empty, specifically for ORM population. You can also specify "*" for all fields |
nullEmptyExclude | string | No | A list of keys to NOT NULL when empty, specifically for ORM population. You can also specify "*" for all fields |
composeRelationships | boolean | No | true | When true, will automatically attempt to compose relationships from memento |
Key | Type | Required | Default | Description |
target | any | Yes | --- | The entity to populate |
qry | query | Yes | --- | The query to populate with |
rowNumber | numeric | false | 1 | The row to use to populate with. |
scope | string | No | --- | Use scope injection instead of setter injection, no need of setters, just tell us what scope to inject to |
trustedSetter | Boolean | No | false | Do not check if the setter exists, just call it, great for usage with onMissingMethod() and virtual properties |
include | string | No | --- | A list of columns to ONLY include in the population |
exclude | string | No | --- | A list of columns to exclude from the population |
nullEmptyInclude | string | No | A list of keys to NULL when empty, specifically for ORM population. You can also specify "*" for all fields |
nullEmptyExclude | string | No | A list of keys to NOT NULL when empty, specifically for ORM population. You can also specify "*" for all fields |
composeRelationships | boolean | No | true | When true, will automatically attempt to compose relationships from memento |
Key | Type | Required | Default | Description |
target | any | Yes | --- | The entity to populate |
xml | any | Yes | --- | The xml string or xml document object to populate with |
root | string | false | The xml root node to start the population with, by default it uses the XMLRoot. |
scope | string | No | Use scope injection instead of setter injection, no need of setters, just tell us what scope to inject to |
trustedSetter | Boolean | No | false | Do not check if the setter exists, just call it, great for usage with onMissingMethod() and virtual properties |
include | string | No | A list of keys to ONLY include in the population |
exclude | string | No | A list of keys to exclude from the population |
nullEmptyInclude | string | No | A list of keys to NULL when empty, specifically for ORM population. You can also specify "*" for all fields |
nullEmptyExclude | string | No | A list of keys to NOT NULL when empty, specifically for ORM population. You can also specify "*" for all fields |
composeRelationships | boolean | No | true | When true, will automatically attempt to compose relationships from memento |
These methods allow you to do counting on entities with or without filtering.
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");
This function returns numeric
Return the count of instances 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 named or positional parameters with this method: Ex: count('User','age > ? AND name = ?',[40,"joe"])
This function returns numeric
Get a brand new criteria builder object to do criteria queries with (See )
Key | Type | Required | Default | Description |
entityName | string | true | --- | The entity name to bind the criteria query to |
useQueryCaching | boolean | false | false | Do automatic query caching for queries |
queryCacheRegion | string | false | criterias.{entityName} | The queryCacheRegion name property for all queries in this criteria object |
datasource | string | false | The datasource to use or default it to the application or entity in use |
Key | Type | Required | Default |
entityName | string | Yes | --- |
Key | Type | Required | Default | Description |
entityName | string | Yes | --- |
where | string | No |
params | any | No | strucnew() | Named or positional parameters |
Key
Type
Required
Default
Description
entityName
any
Yes
---
id
any
Yes
---
Key | Type | Required | Default | Description |
entityName | string | Yes | --- | The entity to purge |
flush | boolean | No | false |
transactional | boolean | No | From Property | Use transactions or not |
These methods allow you to delete one or more entities in cascade style or bulk styles.
Key | type | Required | Default | Description |
entity | any | Yes | --- |
flush | boolean | No | false |
transactional | boolean | No | From Property | Use Transactions or not |
Delete using an entity name and an incoming id, you can also flush the session if needed. The ID can be a single ID or an array of ID's to batch delete using hibernate DLM style deletes. The function also returns the number of records deleted.
No cascading will be done since the delete is done without loading the entity into session but via DLM HQL
This function returns numeric
Key
Type
Required
Default
Description
entityName
string
Yes
---
The name of the entity to delte
id
any
Yes
---
A single ID or array of IDs
flush
boolean
No
false
transactional
boolean
No
From Property
Use transactions not
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);
This function returns numeric
Key
Type
Required
Default
Description
entityName
string
Yes
---
transactional
boolean
No
From Property
Use transactions not
Key | Type | Required | Default | description |
query | string | Yes | --- |
params | any | No | --- |
max | numeric | No | 0 |
offfset | numeric | No | 0 |
flush | boolean | No | false |
transactional | boolean | No | From Property | Use transactions or not |
datasource | string | false | The datasource to use or use the default datasource |
These collection of methods will give you information about the currently loaded entity or the entity class itself.
This method will return to you the hibernate's metadata for a specific entity.
The Hibernate Java ClassMetadata
Object (https://docs.jboss.org/hibernate/orm/3.5/javadocs/org/hibernate/metadata/ClassMetadata.html)
Key
Type
Required
Default
Description
entity
any
Yes
---
The entity name or entity object
Key
Type
Required
Default
Description
entity
any
Yes
---
Key
Type
Required
Default
Description
entity
Any
Yes
---
The entity object
Key
Type
Required
Default
Description
entity
string
Yes
---
The entity name or entity object
Key
Type
Required
Default
Description
entity
string
Yes
---
The entity to inspect for it's id
Key
Type
Required
Default
Description
entity
string
Yes
---
Key
Type
Required
Default
Description
entity
string
Yes
---
Key
Type
Required
Default
Description
entity
Any
Yes
---
The entity object
Finders are convenience methods that will help you find a single entity or a collection of entities by using criterias. If you want to use primary keys, then use the getters.
Key
Type
Required
Default
Description
query
string
No
---
The HQL Query to execute
params
any
No
{}
Positional or named params
timeout
numeric
No
0
ignoreCase
boolean
No
false
datasource
string
No
Key | Type | Required | Default | Description |
entity | any | Yes | --- |
Key | Type | Required | Default | Description |
example | any | Yes | --- | The entity sample |
unique | boolean | false | false | Return an array of sample data or none |
Key
Type
Required
Default
Description
entityName
string
Yes
---
criteria
struct
Yes
---
A structure of criteria to filter on
sortOrder
string
false
---
The sort ordering
ignoreCase
boolean
false
false
timeout
numeric
false
0
asStream
boolean
false
false
Key | Type | Required | Default | Description |
query | string | No | --- | The HQL Query to execute |
params | any | No | [runtime expression] | Named or positional params |
offset | numeric | No | 0 |
max | numeric | No | 0 |
timeout | numeric | No | 0 |
ignoreCase | boolean | No | false |
datasource | string | No |
asStream | boolean | No | false |
Key | Type | Required | Default | Description |
query | string | No | --- | The HQL Query to execute |
params | any | No | {} | Positional or named params |
timeout | numeric | No | 0 |
ignoreCase | boolean | No | false |
datasource | string | No |
Key
Type
Required
Default
Description
entityName
string
Yes
---
id
any
Yes
---
returnNew
boolean
false
true
If id is 0 or empty and this is true, then a new entity is returned.
Key
Type
Required
Default
Description
entityName
string
Yes
---
criteria
struct
Yes
---
A structure of criteria to filter on
Key | Type | Required | Default | Description |
entityName | string | Yes | --- |
id | any | Yes | --- |
Key
Type
Required
Default
Description
datasource
string
false
---
The default or specific datasource use
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. If the id is not found or returns null the array position will have an empty string in it in the specified order
You can use the readOnly
argument to give you the entities as read only entities.
You can use the properties
argument so this method can return to you array of structs instead of array of objects. The property list must include the as
alias if not you will get positional keys.
Example Positional: properties="catID,category
Example Aliases: properties="catID as id, category as category, role as role"
You can use the asStream
boolean argument to get either an array of objects or a Java stream via cbStreams.
No casting is necessary on the Id value type as we do this automatically for you.
This function returns array of entities found
Key
Type
Required
Default
Description
entityName
string
true
---
id
any
false
---
sortOrder
string
false
---
The sort orering of the array
readOnly
boolean
false
false
properties
string
false
If passed, you can retrieve an array of properties of the entity instead of the entire entity. Make sure you add aliases to the properties: Ex: 'catId as id'
asStream
boolean
false
false
Returns the result as a Java Stream using cbStreams
Key
Type
Required
Description
entities
any
Yes
The argument can be one persistence entity or an array of entities to evict
Key
Type
Required
Default
Description
cacheName
string
No
---
datasource
string
No
---
The datasource to use
Key
Type
Required
Default
Description
entityName
string
Yes
---
The entity name to evict or use in the eviction process
relationName
string
false
The name of the relation in the entity to evict
id
any
false
The id to use for eviction according to entity name or relation name
Key
Type
Required
Default
Description
datasource
string
false
---
The default or specific datasource to use
Key
Type
Required
Default
Description
datasource
string
false
---
The default or specific datasource use
Key
Type
Required
Default
Description
entity
any
Yes
---
These methods are used for doing a-la-carte querying of entities with extra pizzaz!
Key
Type
Required
Default
Description
query
string
Yes
---
The valid HQL to process
params
array or struct
No
Positional or named parameters
offset
numeric
No
0
Pagination offset
max
numeric
No
0
Max records to return
timeout
numeric
No
0
Query timeout
asQuery
boolean
No
false
Return query or array of objects
unique
boolean
No
false
Return a unique result
datasource
string
No
---
Use a specific or default datasource
asStream
boolean
No
false
Returns the result as a Java Stream using cbStreams
Here is a collection of useful getter methods for entities by primary identifiers. Getters mostly deal with retrieving entities by primary keys instead of finders which rely on criteria operations. You can use the get()
for a single entity, getOrFail()
for throwing exceptions if an entity is not found and getAll()
for multiple entities.
List all of the instances of the passed in entity class name with or without any filtering of properties, no HQL needed.
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.
This function returns array if asQuery = false
This function returns a query if asQuery = true
This function returns a stream if asStream = true
Key
Type
Required
Default
Description
entityName
string
Yes
---
The entity to list
criteria
struct
No
A struct of filtering criteria for the listing
sortOrder
string
No
The sorting order of the listing
offset
numeric
No
0
Pagination offset
max
numeric
No
0
Max records to return
timeout
numeric
No
0
Query timeout
ignoreCase
boolean
No
false
Case insensitive or case sensitive searches, we default to case sensitive filtering.
asQuery
boolean
No
false
Return query or array of objects
asStream
boolean
No
false
Returns the result as a Java Stream using cbStreams
Key
Type
Required
Default
Description
entity
any
Yes
---
Key | Type | Required | Default | Description |
entity | any | Yes | --- | The entity to save |
forceInsert | boolean | No | false | Insert as new record whether it already exists or not |
flush | boolean | No | false | Do a flush after saving the entity, false by default since we use transactions |
transactional | boolean | No | true | Wrap the save in a ColdFusion transaction |
Key | Type | Required | Default | Description |
entities | array | Yes | --- | The array of entities to persist |
forceInsert | boolean | No | false |
flush | boolean | No | false |
transactional | boolean | No | true | Use ColdFusion transactions or not |
Key | Type | Required | Default |
entityName | string | Yes | --- |
useQueryCaching | boolean | No | Same as BaseService |
queryCacheRegion | string | No | Same as BaseService |
eventHandling | boolean | No | true |
useTransactions | boolean | No | true |
defaultAsQuery | boolean | No | true |
datasource | string | No | The default app datasource |
This method allows you to cast the identifier value to the appropriate type in Java. The entity
argument can be the entity name or an entity object. Please note that this is ONLY used for identifier casting not for any property!
This function returns the value casted to the right Java type
Key
Type
Required
Default
Description
entity
string
Yes
The entity name or entity object
id
any
Yes
The value to cast
Key
Type
Required
Default
Description
entity
string
Yes
The entity name or entity object
propertyName
string
Yes
The property name
value
any
Yes
The property value
Key
Type
Required
Default
Description
target
boolean
Yes
A boolean evaluator
success
closure
Yes
The closure to execute if the target is true
failure
closure
No
The closure to execute if the target is false