Methods Summary |
---|
protected void | clonedQueryExecutionComplete(oracle.toplink.essentials.queryframework.DatabaseQuery query, oracle.toplink.essentials.internal.sessions.AbstractSession session)INTERNAL
Used to give the subclasses oportunity to copy aspects of the cloned query
to the original query. The clones of all the ModifyAllQueries will be added to modifyAllQueries for validation.
super.clonedQueryExecutionComplete(query, session);
if (session.isUnitOfWork()) {
((UnitOfWorkImpl)session).storeModifyAllQuery(query);
}
|
public java.lang.Object | executeInUnitOfWork(oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl unitOfWork, oracle.toplink.essentials.internal.sessions.AbstractRecord translationRow)INTERNAL:
Override query execution where Session is a UnitOfWork.
If there are objects in the cache return the results of the cache lookup.
if (unitOfWork.isNestedUnitOfWork()) {
throw ValidationException.nestedUOWNotSupportedForModifyAllQuery();
}
//Bug4607551 For UpdateAllQuery, if deferred, add the original query with a translation row to the deferredUpdateAllQueries for execution.
//No action for non-deferred. Later on the clones of all the UpdateAllQuery's will be added to modifyAllQueries for validation.
if(shouldDeferExecutionInUOW()) {
unitOfWork.storeDeferredModifyAllQuery(this, translationRow);
result = null;
} else {
if(!unitOfWork.isInTransaction()) {
unitOfWork.beginEarlyTransaction();
}
unitOfWork.setWasNonObjectLevelModifyQueryExecuted(true);
result = (Integer)super.executeInUnitOfWork(unitOfWork, translationRow);
}
return result;
|
public int | getCacheUsage()PUBLIC:
Return the cache usage for this query.
return m_cacheUsage;
|
public oracle.toplink.essentials.expressions.ExpressionBuilder | getExpressionBuilder()PUBLIC:
Get the expression builder which should be used for this query.
This expression builder should be used to build all expressions used by this query.
if (defaultBuilder == null) {
initializeDefaultBuilder();
}
return defaultBuilder;
|
public java.lang.Class | getReferenceClass()PUBLIC:
Return the reference class for this query.
return referenceClass;
|
public java.lang.String | getReferenceClassName()INTERNAL:
Return the name of the reference class of the query.
Used by the Mappign Workbench to avoid classpath dependancies
if ((referenceClassName == null) && (referenceClass != null)) {
referenceClassName = referenceClass.getName();
}
return referenceClassName;
|
protected void | initializeDefaultBuilder()INTERNAL:
Initialize the expression builder which should be used for this query. If
there is a where clause, use its expression builder, otherwise
generate one and cache it. This helps avoid unnecessary rebuilds.
initializeQuerySpecificDefaultBuilder();
if(defaultBuilder == null) {
defaultBuilder = new ExpressionBuilder();
}
|
protected void | initializeQuerySpecificDefaultBuilder()INTERNAL:
Initialize the expression builder which should be used for this query. If
there is a where clause, use its expression builder.
If after this method defaultBuilder is still null,
then initializeDefaultBuilder method will generate and cache it.
DatabaseQueryMechanism mech = getQueryMechanism();
if (mech.isExpressionQueryMechanism() && ((ExpressionQueryMechanism)mech).getExpressionBuilder() != null) {
this.defaultBuilder = ((ExpressionQueryMechanism)mech).getExpressionBuilder();
}
|
protected void | invalidateCache()INTERNAL:
Invalid the cache, that is, those objects in the cache that were affected
by the query.
oracle.toplink.essentials.sessions.IdentityMapAccessor identityMapAccessor = getSession().getIdentityMapAccessor();
if (getSelectionCriteria() == null) {
// Invalidate the whole class since the user did not specify a where clause
if(getDescriptor().isChildDescriptor()) {
Vector collectionToInvalidate = identityMapAccessor.getAllFromIdentityMap(null, getReferenceClass(), getTranslationRow(), null);
identityMapAccessor.invalidateObjects(collectionToInvalidate);
} else {
// if it's either a root class or there is no inheritance just clear the identity map
identityMapAccessor.invalidateClass(getReferenceClass());
}
} else {
// Invalidate only those objects in the cache that match the selection criteria
//Bug:4293920, expression parameters were not passed in
boolean noObjectsModifiedInDb = result != null && result.intValue() == 0;
try {
InMemoryQueryIndirectionPolicy policy = new InMemoryQueryIndirectionPolicy();
if(noObjectsModifiedInDb) {
policy.ignoreIndirectionExceptionReturnNotConformed();
} else {
policy.ignoreIndirectionExceptionReturnConformed();
}
Vector collectionToInvalidate = identityMapAccessor.getAllFromIdentityMap(getSelectionCriteria(), getReferenceClass(), getTranslationRow(), policy);
identityMapAccessor.invalidateObjects(collectionToInvalidate);
} catch (QueryException ex) {
if(ex.getErrorCode() == QueryException.CANNOT_CONFORM_EXPRESSION) {
// If no objects changed in the db - don't invalidate, ignore.
if(!noObjectsModifiedInDb) {
// Invalidate the whole class since the expression can't be selected in memory
identityMapAccessor.invalidateClass(getReferenceClass());
}
} else {
throw ex;
}
}
}
|
public boolean | isModifyQuery()PUBLIC:
Return true if this is a modify query.
return true;
|
public boolean | isPreparedUsingTempStorage()INTERNAL:
return isPreparedUsingTempStorage;
|
public void | mergeChangesIntoSharedCache()INTERNAL:
After execution we need to merge the changes into the shared cache
if (shouldInvalidateCache()) {
invalidateCache();
}
|
public void | setCacheUsage(int cacheUsage)PUBLIC:
Set the level of cache support for this query, either NONE or INVALIDATE.
m_cacheUsage = cacheUsage;
|
public void | setExpressionBuilder(oracle.toplink.essentials.expressions.ExpressionBuilder builder)INTERNAL
Sets the default expression builder for this query.
this.defaultBuilder = builder;
|
public void | setIsPreparedUsingTempStorage(boolean isPreparedUsingTempStorage)INTERNAL:
this.isPreparedUsingTempStorage = isPreparedUsingTempStorage;
|
public void | setReferenceClass(java.lang.Class referenceClass)PUBLIC:
Set the reference class this query.
if (this.referenceClass != referenceClass) {
setIsPrepared(false);
}
this.referenceClass = referenceClass;
|
public void | setReferenceClassName(java.lang.String className)INTERNAL:
Set the class name of the reference class of this query.
Used by the Mapping Workbench to avoid classpath dependancies.
referenceClassName = className;
|
public void | setShouldDeferExecutionInUOW(boolean shouldDeferExecutionInUOW)PUBLIC:
Set a flag indicating whether execution should be deferred in UOW until commit.
this.shouldDeferExecutionInUOW = shouldDeferExecutionInUOW;
|
public boolean | shouldDeferExecutionInUOW()PUBLIC:
Indicates whether execution should be deferred in UOW until commit.
return shouldDeferExecutionInUOW;
|
protected boolean | shouldInvalidateCache()INTERNAL:
return m_cacheUsage == INVALIDATE_CACHE;
|