|
ColdBox Platform Version 2.6.4 | ||||
| FRAMES | |||||
WEB-INF.cftags.component
coldbox.system.orm.hibernate.BaseORMService
public class BaseORMService
******************************************************************************* Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp www.coldbox.org | www.luismajano.com | www.ortussolutions.com ******************************************************************************* Author : Luis Majano Description : This is a helper ORM service that will help you abstract some complexities when dealing with CF's ORM via Hibernate. You can use this service in its concrete form or you can inherit from it and extend it. TODO: - Add dynamic findBy methods - Add dynamic countBy methods - Add dynamic getBy methods - Dynamic entity methods for the following methods: - new{entityName}() - exists{entityName}() - get{entityName}() - getAll{entityName}() - count{entityName}() - Add find methods by criteria with projections - Add validations maybe via Hyrule, but more implicit and mixin methods - Add dml style batch updates ----------------------------------------------------------------------->
| Constructor Summary | |
|---|---|
init([string queryCacheRegion='ORMService.defaultCache'], [boolean useQueryCaching='false'])
Constructor |
|
| Method Summary | |
|---|---|
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 |
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 |
clear()
Clear the session removes all the entities that are loaded or created in the session |
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 |
any |
createService(string entityName, [boolean useQueryCaching='[runtime expression]'], [string queryCacheRegion='[runtime expression]'])
Create a virtual abstract service for a specfic entity |
void |
delete(any entity, [boolean flush='false'])
Delete an entity using hibernate transactions |
boolean |
deleteByID(string entityName, any id, [boolean flush='false'])
Delete using an entity name and an incoming id, you can also flush the session if needed The method returns false if the passed in entityName and id is not found in the database |
void |
deleteByQuery(string query, [any params], [numeric max='0'], [numeric offset='0'], [boolean flush='false'])
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 |
numeric |
deleteWhere(string entityName)
Deletes entities by using name value pairs as arguments to this function |
void |
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 |
void |
evictEntity(any entity)
Evict entity objects from session |
void |
evictQueries([string cacheName])
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 asQuery='true'])
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 |
any |
find([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 |
array |
findAll([string query], [any params='[runtime expression]'], [numeric offset='0'], [numeric max='0'], [any example])
Find all the entities for the specified query and params or example |
array |
findAllWhere(string entityName)
Find one entity or null if not found according to the passed in name value pairs into the function ex: findWhere(entityName="Category", category="Training"), findWhere(entityName="Users", age=40); |
any |
findWhere(string entityName)
Find one entity or null if not found according to the passed in name value pairs into the function ex: findWhere(entityName="Category", category="Training"), findWhere(entityName="Users", age=40); |
any |
get(string entityName, any id)
Get an entity using a primary key, if the id is not found this method returns null |
array |
getAll(string entityName, [any id])
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 |
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 |
struct |
getSessionStatistics()
Information about the first-level (session) cache for the current session |
string |
getTableName(string entityName)
Returns the table name of the of the entity |
boolean |
isSessionDirty()
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='true'])
List all of the instances of the passed in entity class name |
void |
merge(any entity)
Merge an entity or array of entities back into the session |
any |
new(string entityName)
Get a new entity object by entity name and you can pass in any named parameter and the method will try to set it for you |
any |
onMissingMethod([String missingMethodName], [Struct missingMethodArguments])
A nice onMissingMethod template to create awesome dynamic methods |
void |
refresh(any entity)
Refresh the state of an entity or array of entities from the database |
void |
save(any entity, [boolean forceInsert='false'], [boolean flush='false'])
Save an entity using hibernate transactions |
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'])
queryCacheRegionuseQueryCaching| Method Detail |
|---|
public string GETQUERYCACHEREGION()
public boolean GETUSEQUERYCACHING()
public void SETQUERYCACHEREGION(string queryCacheRegion)
queryCacheRegionpublic void SETUSEQUERYCACHING(boolean useQueryCaching)
useQueryCachingpublic void clear()
public numeric count(string entityName, [string where=''], [any params='[runtime expression]'])
entityNamewhereparamspublic numeric countWhere(string entityName)
entityNamepublic any createService(string entityName, [boolean useQueryCaching='[runtime expression]'], [string queryCacheRegion='[runtime expression]'])
entityNameuseQueryCachingqueryCacheRegionpublic void delete(any entity, [boolean flush='false'])
entityflushpublic boolean deleteByID(string entityName, any id, [boolean flush='false'])
entityNameidflushpublic void deleteByQuery(string query, [any params], [numeric max='0'], [numeric offset='0'], [boolean flush='false'])
queryparamsmaxoffsetflushpublic numeric deleteWhere(string entityName)
entityNamepublic void evict(string entityName, [string collectionName], [any id])
entityNamecollectionNameidpublic void evictEntity(any entity)
entitypublic void evictQueries([string cacheName])
cacheNamepublic any executeQuery(string query, [any params='[runtime expression]'], [numeric offset='0'], [numeric max='0'], [numeric timeout='0'], [boolean asQuery='true'])
queryparamsoffsetmaxtimeoutasQuerypublic boolean exists(any entityName, any id)
entityNameidpublic any find([string query], [any params='[runtime expression]'], [any example])
queryparamsexamplepublic array findAll([string query], [any params='[runtime expression]'], [numeric offset='0'], [numeric max='0'], [any example])
queryparamsoffsetmaxexamplepublic array findAllWhere(string entityName)
entityNamepublic any findWhere(string entityName)
entityNamepublic any get(string entityName, any id)
entityNameidpublic array getAll(string entityName, [any id])
entityNameidpublic any getKey(string entityName)
entityNamepublic array getPropertyNames(string entityName)
entityNamepublic struct getSessionStatistics()
public string getTableName(string entityName)
entityNamepublic boolean isSessionDirty()
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='true'])
entityNamecriteriasortOrderoffsetmaxtimeoutignoreCaseasQuerypublic void merge(any entity)
entitypublic any new(string entityName)
entityNamepublic any onMissingMethod([String missingMethodName], [Struct missingMethodArguments])
missingMethodNamemissingMethodArgumentspublic void refresh(any entity)
entitypublic void save(any entity, [boolean forceInsert='false'], [boolean flush='false'])
entityforceInsertflushpublic boolean sessionContains(any entity)
entity
|
ColdBox Platform Version 2.6.4 | ||||
| FRAMES | |||||