|
ColdBox Platform Version 3.7.0 | ||||
FRAMES |
WEB-INF.cftags.componentcoldbox.system.orm.hibernate.BaseORMService
public class BaseORMService
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 |
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 |
void |
SETDEFAULTASQUERY(boolean defaultAsQuery)
set: The bit that determines the default return value for list(), createCriteriaQuery() and executeQuery() as query or array |
void |
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 |
void |
SETHQLDYNAMICCACHE(struct HQLDynamicCache)
set: All calculated and parsed dynamic finders' and counters' HQL will be stored here for easier execution |
void |
SETQUERYCACHEREGION(string queryCacheRegion)
set: The queryCacheRegion name property for all query caching produced in this service |
void |
SETUSEQUERYCACHING(boolean useQueryCaching)
set: The bit that tells the service to enable query caching, disabled by default |
void |
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 |
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 |
---|
|
Constructor Detail |
---|
public init([string queryCacheRegion='ORMService.defaultCache'], [boolean useQueryCaching='false'], [boolean eventHandling='true'], [boolean useTransactions='true'], [boolean defaultAsQuery='true'])
queryCacheRegion
useQueryCaching
eventHandling
useTransactions
defaultAsQuery
Method Detail |
---|
private any $delete(any entity, [boolean flush='false'])
entity
flush
private numeric $deleteAll(string entityName, [boolean flush='false'])
entityName
flush
private numeric $deleteByID(string entityName, any id, [boolean flush='false'])
entityName
id
flush
private any $deleteByQuery(string query, [any params], [numeric max='0'], [numeric offset='0'], [boolean flush='false'], [string datasource=''])
query
params
max
offset
flush
datasource
private numeric $deleteWhere(string entityName)
entityName
public any $save(any entity, [boolean forceInsert='false'], [boolean flush='false'])
entity
forceInsert
flush
private any $saveAll(any entities, [any forceInsert='false'], [any flush='false'])
entities
forceInsert
flush
private any $transactioned([any method], [any argCollection='[runtime expression]'])
method
- the method to closureargCollection
- the arguments to passthroughpublic boolean GETDEFAULTASQUERY()
public boolean GETEVENTHANDLING()
public struct GETHQLDYNAMICCACHE()
public string GETQUERYCACHEREGION()
public boolean GETUSEQUERYCACHING()
public boolean GETUSETRANSACTIONS()
public void SETDEFAULTASQUERY(boolean defaultAsQuery)
defaultAsQuery
public void SETEVENTHANDLING(boolean eventHandling)
eventHandling
public void SETHQLDYNAMICCACHE(struct HQLDynamicCache)
HQLDynamicCache
public void SETQUERYCACHEREGION(string queryCacheRegion)
queryCacheRegion
public void SETUSEQUERYCACHING(boolean useQueryCaching)
useQueryCaching
public void SETUSETRANSACTIONS(boolean useTransactions)
useTransactions
public any clear([string datasource='[runtime expression]'])
datasource
private any compileHQLFromDynamicMethod([string missingMethodName], [struct missingMethodArguments], [boolean unique='true'], [boolean isCounting='false'], [struct params], [any entityName])
missingMethodName
missingMethodArguments
unique
isCounting
params
entityName
public any convertIDValueToJavaType(any entityName, any id)
entityName
id
public any convertValueToJavaType(any entityName, any propertyName, any value)
entityName
propertyName
value
public numeric count(string entityName, [string where=''], [any params='[runtime expression]'])
entityName
where
params
public numeric countWhere(string entityName)
entityName
private any createCriteriaQuery(any entityName, [array criteria='[runtime expression]'])
entityName
criteria
public any createService(string entityName, [boolean useQueryCaching='[runtime expression]'], [string queryCacheRegion='[runtime expression]'], [boolean eventHandling='[runtime expression]'])
entityName
useQueryCaching
queryCacheRegion
eventHandling
public numeric criteriaCount(any entityName, [array criteria='[runtime expression]'])
entityName
criteria
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]'])
entityName
criteria
sortOrder
offset
max
timeout
ignoreCase
asQuery
public any delete(any entity, [boolean flush='false'], [boolean transactional='[runtime expression]'])
entity
flush
transactional
public numeric deleteAll(string entityName, [boolean flush='false'], [boolean transactional='[runtime expression]'])
entityName
flush
transactional
public numeric deleteByID(string entityName, any id, [boolean flush='false'], [boolean transactional='[runtime expression]'])
entityName
id
flush
transactional
public any deleteByQuery(string query, [any params], [numeric max='0'], [numeric offset='0'], [boolean flush='false'], [boolean transactional='[runtime expression]'], [string datasource=''])
query
params
max
offset
flush
transactional
datasource
public numeric deleteWhere(string entityName, [boolean transactional='[runtime expression]'])
entityName
transactional
public any evict(string entityName, [string collectionName], [any id])
entityName
collectionName
id
public any evictEntity(any entities)
entities
- The argument can be one persistence entity or an array of entitiespublic any evictQueries([string cacheName], [string datasource])
cacheName
datasource
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=''])
query
params
offset
max
timeout
ignorecase
asQuery
unique
datasource
public boolean exists(any entityName, any id)
entityName
id
public array findAll([string query], [any params='[runtime expression]'], [numeric offset='0'], [numeric max='0'], [numeric timeout='0'], [boolean ignoreCase='false'], [any example])
query
params
offset
max
timeout
ignoreCase
example
public array findAllWhere(string entityName, struct criteria, [string sortOrder=''])
entityName
criteria
sortOrder
public any findByExample([any example], [boolean unique='false'])
example
unique
public any findDynamically([string missingMethodName], [struct missingMethodArguments], [boolean unique='true'], [boolean isCounting='false'])
missingMethodName
missingMethodArguments
unique
isCounting
public any findIt([string query], [any params='[runtime expression]'], [any example])
query
params
example
- DEPRECATED. Use findByExample() instead, deprecated by 3.5public any findWhere(string entityName, struct criteria)
entityName
criteria
public any get(string entityName, any id, [boolean returnNew='true'])
entityName
- the name of the entity to retrieveid
- An optional primary key to use to retrieve the entity, if the id is 0 or emptyreturnNew
public array getAll(string entityName, [any id], [string sortOrder=''])
entityName
id
sortOrder
public any getEntityGivenName(any entity)
entity
public any getKey(string entityName)
entityName
public array getPropertyNames(string entityName)
entityName
public any getRestrictions()
public struct getSessionStatistics([string datasource='[runtime expression]'])
datasource
public string getTableName(string entityName)
entityName
public boolean isSessionDirty([string datasource='[runtime expression]'])
datasource
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]'])
entityName
criteria
sortOrder
offset
max
timeout
ignoreCase
asQuery
public any merge(any entity)
entity
public any new(string entityName, [struct properties='[runtime expression]'], [boolean composeRelationships='true'], [any nullEmptyInclude=''], [any nullEmptyExclude=''], [boolean ignoreEmpty='false'], [any include=''], [any exclude=''])
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 mementopublic any newCriteria(string entityName, [boolean useQueryCaching='false'], [string queryCacheRegion=''])
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}public any onMissingMethod([string missingMethodName], [struct missingMethodArguments])
missingMethodName
missingMethodArguments
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'])
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
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'])
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
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'])
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
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'])
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
public any refresh(any entity)
entity
public any save(any entity, [boolean forceInsert='false'], [boolean flush='false'], [boolean transactional='[runtime expression]'])
entity
forceInsert
flush
transactional
public any saveAll(any entities, [any forceInsert='false'], [any flush='false'], [boolean transactional='[runtime expression]'])
entities
- An array of entities to saveforceInsert
flush
transactional
public boolean sessionContains(any entity)
entity
|
ColdBox Platform Version 3.7.0 | ||||
FRAMES |