ORMGetSessionFactory()
Returns the Hibernate SessionFactory for the given datasource.
ORMGetSessionFactory( datasource=string );
Returns: object
| Argument | Description |
|---|---|
|
datasource
string,
optional
|
edit
datasource used for the session. if not defined, the datasource defined in application.cfc/cfapplication will be used. |
Usage Notes
editReturns the org.hibernate.SessionFactory for the given datasource. The SessionFactory is built once at application start and lives for the application lifetime.
If ORM is not enabled for that datasource, an exception will be thrown.
Useful for advanced operations like inspecting entity metadata, checking the active dialect, or accessing cache regions.
See ORM - Logging and Debugging for debugging techniques using the SessionFactory.
Examples
editfactory = ORMGetSessionFactory();
// Inspect entity metadata
meta = factory.getClassMetadata( "User" );
systemOutput( "Properties: #arrayToList( meta.getPropertyNames() )#", true );
systemOutput( "ID property: #meta.getIdentifierPropertyName()#", true );
// Check the active dialect
dialect = factory.getDialect();
systemOutput( "Dialect: #dialect.getClass().getName()#", true );
See also
- ORM
- ORM - Logging and Debugging
- Search Issue Tracker open_in_new
- Search Lucee Test Cases open_in_new (good for further, detailed examples)