use of org.eclipse.persistence.internal.databaseaccess.DatasourceCall in project eclipselink by eclipse-ee4j.
the class DescriptorQueryManager method putCachedUpdateCalls.
/**
* INTERNAL:
* Cache a clone of the update SQL calls based on the updated fields.
* If the max size is reached, do not cache the call.
* The call's query must be dereferenced in order to allow the GC of a related session.
* PERF: Allow caching of the update SQL call to avoid regeneration.
*/
public void putCachedUpdateCalls(Vector updateFields, Vector updateCalls) {
Vector vectorToCache = updateCalls;
if (!updateCalls.isEmpty()) {
int updateCallsSize = updateCalls.size();
vectorToCache = new NonSynchronizedVector(updateCallsSize);
for (int i = 0; i < updateCallsSize; i++) {
DatasourceCall updateCall = (DatasourceCall) updateCalls.get(i);
// clone call and dereference query for DatasourceCall and EJBQLCall
DatasourceCall clonedUpdateCall = (DatasourceCall) updateCall.clone();
clonedUpdateCall.setQuery(null);
vectorToCache.add(clonedUpdateCall);
}
}
getCachedUpdateCalls().put(updateFields, vectorToCache);
}
use of org.eclipse.persistence.internal.databaseaccess.DatasourceCall in project eclipselink by eclipse-ee4j.
the class DatasourceCallQueryMechanism method deleteAll.
/**
* INTERNAL:
* Delete a collection of objects. Assume call is correct.
* @exception DatabaseException - an error has occurred on the database
*/
@Override
public Integer deleteAll() throws DatabaseException {
if (((DeleteAllQuery) this.query).isPreparedUsingTempStorage()) {
return deleteAllUsingTempTables();
} else {
if (hasMultipleCalls()) {
Integer returnedRowCount = null;
// Deletion must occur in reverse order.
for (int index = getCalls().size() - 1; index >= 0; index--) {
DatasourceCall databseCall = (DatasourceCall) getCalls().elementAt(index);
returnedRowCount = (Integer) executeCall(databseCall);
}
// returns the number of rows removed from the first table in insert order
return returnedRowCount;
} else {
return (Integer) executeCall();
}
}
}
use of org.eclipse.persistence.internal.databaseaccess.DatasourceCall in project eclipselink by eclipse-ee4j.
the class DatasourceCallQueryMechanism method prepareExecuteSelect.
/**
* Pre-build configure the call.
*/
@Override
public void prepareExecuteSelect() {
if (hasMultipleCalls()) {
for (Enumeration callsEnum = getCalls().elements(); callsEnum.hasMoreElements(); ) {
DatasourceCall databseCall = (DatasourceCall) callsEnum.nextElement();
databseCall.returnManyRows();
}
} else {
getCall().returnManyRows();
}
prepareCall();
}
use of org.eclipse.persistence.internal.databaseaccess.DatasourceCall in project eclipselink by eclipse-ee4j.
the class DatasourceCallQueryMechanism method deleteAllUsingTempTables.
/**
* Execute deleteAll using temp tables
* @exception DatabaseException - an error has occurred on the database.
* @return the row count.
*/
public Integer deleteAllUsingTempTables() throws DatabaseException {
DatabaseException ex = null;
Integer returnedRowCount = null;
// may fail in case global temp table already exists.
try {
DatasourceCall databseCall = (DatasourceCall) getCalls().elementAt(getCalls().size() - 1);
executeCall(databseCall);
} catch (DatabaseException databaseEx) {
// ignore
}
// if that fails save the exception and untill cleanup
try {
DatasourceCall databseCall = (DatasourceCall) getCalls().elementAt(getCalls().size() - 2);
executeCall(databseCall);
} catch (DatabaseException databaseEx) {
ex = databaseEx;
}
// if that fails save the exception untill cleanup
for (int index = getCalls().size() - 3; index >= 1 && ex == null; index--) {
DatasourceCall databseCall = (DatasourceCall) getCalls().elementAt(index);
try {
// returns the number of rows removed from the first table in insert order
returnedRowCount = (Integer) executeCall(databseCall);
} catch (DatabaseException databaseEx) {
ex = databaseEx;
}
}
// ignore exceptions here.
try {
DatasourceCall databseCall = (DatasourceCall) getCalls().elementAt(0);
executeCall(databseCall);
} catch (DatabaseException databaseEx) {
// ignore
}
if (ex != null) {
throw ex;
}
return returnedRowCount;
}
use of org.eclipse.persistence.internal.databaseaccess.DatasourceCall in project eclipselink by eclipse-ee4j.
the class DatasourceCallQueryMechanism method prepareSelectAllRows.
/**
* Pre-build configure the call.
*/
@Override
public void prepareSelectAllRows() {
if (hasMultipleCalls()) {
for (Enumeration callsEnum = getCalls().elements(); callsEnum.hasMoreElements(); ) {
DatasourceCall databseCall = (DatasourceCall) callsEnum.nextElement();
databseCall.returnManyRows();
}
} else {
getCall().returnManyRows();
}
prepareCall();
}
Aggregations