// This can be avoided by setting check cache by (inexact/exact) primary key on the query.
// That flag becomes invalid in the conforming case (bug 2609611: SUPPORT CONFORM RESULT IN UOW IN CONJUNCTION WITH OTHER IN-MEMORY FEATURES)
// so if conforming must always do this linear search, but at least only on
// objects registered in the UnitOfWork.
//
boolean conformingButOutsideUnitOfWork = ((query.shouldConformResultsInUnitOfWork() || descriptor.shouldAlwaysConformResultsInUnitOfWork()) && !session.isUnitOfWork());
if ((cachedObject == null) && (conforming || (!query.shouldCheckCacheByPrimaryKey() && !conformingButOutsideUnitOfWork))) {
// PERF: 3639015 - cloning the expression no longer required
// when using the root session
if (selectionCriteria != null) {
ExpressionBuilder builder = selectionCriteria.getBuilder();