Search in sources :

Example 1 with ORMDatasourceConnection

use of lucee.runtime.orm.ORMDatasourceConnection in project Lucee by lucee.

the class DatasourceManagerImpl method _add.

private void _add(PageContext pc, ORMSession session, DataSource ds) throws PageException {
    // ORMDatasourceConnection newDC = new ORMDatasourceConnection(pc,session,ds);
    DatasourceConnectionPro existingDC = null;
    try {
        existingDC = (DatasourceConnectionPro) transConns.get(ds);
        // 
        if (existingDC == null) {
            if (isolation == Connection.TRANSACTION_NONE)
                isolation = Connection.TRANSACTION_SERIALIZABLE;
            ORMDatasourceConnection newDC = new ORMDatasourceConnection(pc, session, ds, isolation);
            transConns.put(ds, newDC);
            return;
        }
        if (!DatasourceConnectionImpl.equals(existingDC, ds, null, null)) {
            // releaseConnection(pc,newDC);
            throw new DatabaseException("can't use different connections to the same datasource inside a single transaction", null, null, existingDC);
        }
        if (existingDC.isAutoCommit()) {
            existingDC.setAutoCommit(false);
        }
        return;
    } catch (SQLException e) {
        // ExceptionHandler.printStackTrace(e);
        throw new DatabaseException(e, null, existingDC);
    }
}
Also used : ORMDatasourceConnection(lucee.runtime.orm.ORMDatasourceConnection) SQLException(java.sql.SQLException) DatabaseException(lucee.runtime.exp.DatabaseException)

Aggregations

SQLException (java.sql.SQLException)1 DatabaseException (lucee.runtime.exp.DatabaseException)1 ORMDatasourceConnection (lucee.runtime.orm.ORMDatasourceConnection)1