ORMGetSessionFactory()

edit

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

edit

Returns 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

edit
factory = 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