use of lucee.runtime.orm.ORMConnection in project Lucee by lucee.
the class DatasourceManagerImpl method end.
public void end(boolean onlyORM) {
autoCommit = true;
Pair<DatasourceConnection, Exception> pair = null;
if (transConns.size() > 0) {
Map<DataSource, DatasourceConnection> tmp = null;
if (onlyORM)
tmp = new HashMap<DataSource, DatasourceConnection>();
Iterator<Entry<DataSource, DatasourceConnection>> it = this.transConns.entrySet().iterator();
DatasourceConnection dc;
Entry<DataSource, DatasourceConnection> entry;
while (it.hasNext()) {
entry = it.next();
dc = entry.getValue();
try {
if (onlyORM && !(dc.getConnection() instanceof ORMConnection)) {
tmp.put(entry.getKey(), entry.getValue());
continue;
}
dc.getConnection().setAutoCommit(true);
} catch (Exception e) {
// we only keep the first exception
if (pair == null) {
pair = new Pair<DatasourceConnection, Exception>(dc, e);
}
}
releaseConnection(null, dc);
}
transConns.clear();
if (onlyORM)
transConns = tmp;
}
this.isolation = Connection.TRANSACTION_NONE;
if (pair != null) {
if (pair.getValue() instanceof SQLException) {
throw new PageRuntimeException(new DatabaseException((SQLException) pair.getValue(), pair.getName()));
}
throw new PageRuntimeException(pair.getValue());
}
}
Aggregations