ColdBox/coldbox-platform — pull request #61 by mmckellip (2011-12-06 15:25:48+00:00)
Title: Development

Changes for multiple datasources with hibernate ORM

BaseORMService.cfc
ORMFlush() changed to ORMFlushAll() to make sure sessions for all datasources are flushed.

Three utility methods added:
getEntityDatasource(required entity) - entity passed can be an object or entityName

$ORMGetSession(required entity) - returns correct session based by entity datasource.

$ORMGetSessionfactory(required entity) - returns correct session factory based on entity datasource

The following methods were updated with an optional datasource argument. Will use DEFAULT datasource for session if not provided.

executeQuery()
deleteByQuery()
evictQueries()
clear()
isSessionDirty()
getSessionStatistics()

Remaining methods utilize $ORMGetSession(entity) or $ORMGet Session Factory(entity) to get correct session.

* The findIt() and findAll() methods were not updated as they were marked as DEPRECATED in 3.5

VirtualEntityService.cfc
Added a datasource property. Populated during the init based upon the entityName

Added facade methods for the following methods. Adds datasource argument before calling super.[method]. Maintains signature and backward compatibility:

executeQuery()
deleteByQuery()
clear()
isSessionDirty()
getSessionStatistics()

EventHandler.cfc
Updated postLoad() to get the correct session based on entity datasource.

CriteriaBuilder.cfc
Updated the init() method to get the correct session based on the datasource of the passed in entityName.

HibernateTransaction.cfc
Updated invokeMethod() with optional datasource argument. DEFAULTS to datasource specified in Application.cfc.

Updated transaction begin to get the correct session based on datasource.