Parameter
Multiple data source support impacts the following ORM functions:
ORMGetSession
Description
Returns the Hibernate session associated with the data source in the request. If ORM is not configured for this data source, it results in an exception. If data source is not specified, the Hibernate session of the default data source is returned.
Use this session object to call the APIs, which, otherwise, ColdFusion does not expose.
For information on session APIs, see: http://docs.jboss.org/hibernate/core/3.3/api/org/hibernate/Session.html
Function syntax
ormgetsession([datasource])
ORMCloseSession
Description
Closes the Hibernate session associated with the data source in the request. If you do not specify a data source, the Hibernate session associated with the default data source is closed.
Function syntax
ormcloseallsessions()
ORMCloseAllSessions
Description
Closes all Hibernate sessions in the request.
Function Syntax
ormcloseallsessions()
History
ColdFusion 9 Update 1: Added this function
ORMFlush
Description
Flushes the Hibernate session associated with the data source in the request. ORMFlush flushes all pending CRUD operations in the request. Any changes made in the objects, in the current ORM session, are saved to the database. If you do not specify the data source, the Hibernate session associated with the default data source is flushed.
Function syntax
ormflush([datasource])
ORMFlushall
Description
Flushes all the current Hibernate sessions in the request.
Function syntax
ormflushall()
History
ColdFusion 9 Update 1: Added this function
ORMClearSession
Description
Clears the Hibernate session associated with the given data source.The function clears the first level cache and removes the objects that are not yet saved to the database.If you do not specify the data source, the Hibernate session associated with the default data source is cleared.
Function syntax
Ormclearsession([datasource])
ORMGetSessionFactory
Description
Returns the Hibernate Session Factory object associated with the data source. Results in an error if ORM is not configured for this data source. If you do not specify the data source, the Hibernate session factory object associated with the default data source is returned.
For information on Session API, go to the following URL: http://docs.jboss.org/hibernate/core/3.3/api/org/hibernate/SessionFactory.html
Function syntax
Ormgetsessionfactory([datasource])
ORMEvictQueries
Description
This method is used to evict the data of all the queries from the default query cache of the specified data source. If cache name is specified, then the data of all queries belonging to the cache region with the given cache name are evicted.If no data source is specified, the default query cache of the default data source is evicted.
Syntax
{{ORMEvictQueries([cachename])
ORMEvictQueries([cachename], datasource)}}
|
Description |
---|---|
cachename |
Name of the cache region that you want to evict. |
datasource |
Name of the data source whose cache you want to evict. If you do not specify the cache, the default query cache is evicted. |
ORMExecuteQuery
Description
Executes a Hibernate Query Language (HQL) query.By default, this function works on ORM's default data source. To use this function for another data source, specify the data source key-value pair within the queryoptions.
Syntax
{{ORMExecuteQuery(hql, [params] [,unique])
ORMExecuteQuery(hql, [,unique] [, queryoptions])
ORMExecuteQuery(hql, params [,unique] [,queryOptions])}}
Parameters
Parameter |
Description |
---|---|
Hql |
The HQL query that has to be executed. |
Params |
Object parameter for the entity. |
Unique |
Specifies if the object parameter is unique. |
Queryoptions |
Key-value pair of options for the query. |
Example
<cfset artistArr = ORMExecuteQuery("from Artists where artistid=1", true, {datasource="cfartgallery"})> <cfset countArray = ORMExecuteQuery("select count(*) from Authors", \[], false, {datasource="cfbookclub"})>