use of org.eclipse.persistence.internal.databaseaccess.DatabaseCall in project eclipselink by eclipse-ee4j.
the class ServerSession method executeCall.
/**
* INTERNAL:
* Execute the call on the correct connection accessor.
* By default the server session executes calls using is read connection pool.
* A connection is allocated for the execution of the query, then released back to the pool.
* If partitioning is used the partition policy can use a different connection pool, or even
* execute the call on multiple connections.
*/
@Override
public Object executeCall(Call call, AbstractRecord translationRow, DatabaseQuery query) throws DatabaseException {
RuntimeException exception = null;
Object result = null;
boolean accessorAllocated = false;
if (query.getAccessors() == null) {
List<Accessor> accessors = getAccessors(call, translationRow, query);
query.setAccessors(accessors);
if (this.eventManager != null) {
for (Accessor accessor : accessors) {
// if connection is using external connection pooling then the event will be risen right after it connects.
if (!accessor.usesExternalConnectionPooling()) {
this.eventManager.postAcquireConnection(accessor);
}
}
}
accessorAllocated = true;
}
try {
result = basicExecuteCall(call, translationRow, query);
} catch (RuntimeException caughtException) {
exception = caughtException;
} finally {
// or unless an exception occurred executing the call.
if (call.isFinished() || exception != null) {
if (accessorAllocated) {
try {
releaseConnectionAfterCall(query);
} catch (RuntimeException releaseException) {
if (exception == null) {
throw releaseException;
}
// else ignore
}
}
} else {
if (query.isObjectLevelReadQuery()) {
((DatabaseCall) call).setHasAllocatedConnection(accessorAllocated);
}
}
if (exception != null) {
throw exception;
}
}
return result;
}
Aggregations