/** * For executing all reads on the UnitOfWork, the session when building * objects from rows will now be the UnitOfWork. Useful if the rows were * read via a dirty write connection and we want to avoid putting uncommitted * data in the global cache. * <p> * Decides whether to call either buildWorkingCopyCloneFromRow (bypassing * shared cache) or buildWorkingCopyCloneNormally (placing the result in the * shared cache). */ protected Object buildObjectInUnitOfWork(ObjectBuildingQuery query, JoinedAttributeManager joinManager, AbstractRecord databaseRow, UnitOfWorkImpl unitOfWork, Vector primaryKey, ClassDescriptor concreteDescriptor) throws DatabaseException, QueryException { // When in transaction we are reading via the write connection // and so do not want to corrupt the shared cache with dirty objects. // Hence we build and refresh clones directly from the database row. // PERF: Allow the session cached to still be used after early transaction if isolation setting has been set. if (!concreteDescriptor.shouldUseSessionCacheInUnitOfWorkEarlyTransaction()) { if (((unitOfWork.hasCommitManager() && unitOfWork.getCommitManager().isActive()) || unitOfWork.wasTransactionBegunPrematurely() || concreteDescriptor.shouldIsolateObjectsInUnitOfWork() || query.shouldStoreBypassCache()) && (!unitOfWork.isClassReadOnly(concreteDescriptor.getJavaClass(), concreteDescriptor))) { // It is easier to switch once to the correct builder here. return concreteDescriptor.getObjectBuilder().buildWorkingCopyCloneFromRow(query, joinManager, databaseRow, unitOfWork, primaryKey); } } return buildWorkingCopyCloneNormally(query, databaseRow, unitOfWork, primaryKey, concreteDescriptor, joinManager); }
/** * For executing all reads on the UnitOfWork, the session when building * objects from rows will now be the UnitOfWork. Useful if the rows were * read via a dirty write connection and we want to avoid putting uncommitted * data in the global cache. * <p> * Decides whether to call either buildWorkingCopyCloneFromRow (bypassing * shared cache) or buildWorkingCopyCloneNormally (placing the result in the * shared cache). */ protected Object buildObjectInUnitOfWork(ObjectBuildingQuery query, JoinedAttributeManager joinManager, AbstractRecord databaseRow, UnitOfWorkImpl unitOfWork, Object primaryKey, CacheKey preFetchedCacheKey, ClassDescriptor concreteDescriptor) throws DatabaseException, QueryException { // When in transaction we are reading via the write connection // and so do not want to corrupt the shared cache with dirty objects. // Hence we build and refresh clones directly from the database row. // PERF: Allow the session cached to still be used after early transaction if isolation setting has been set. CachePolicy cachePolicy = concreteDescriptor.getCachePolicy(); if (!cachePolicy.shouldUseSessionCacheInUnitOfWorkEarlyTransaction()) { if (((unitOfWork.hasCommitManager() && unitOfWork.getCommitManager().isActive()) || unitOfWork.wasTransactionBegunPrematurely() || cachePolicy.shouldIsolateObjectsInUnitOfWork() || cachePolicy.shouldIsolateProtectedObjectsInUnitOfWork() || query.shouldStoreBypassCache()) && (!unitOfWork.isClassReadOnly(concreteDescriptor.getJavaClass(), concreteDescriptor))) { // It is easier to switch once to the correct builder here. return concreteDescriptor.getObjectBuilder().buildWorkingCopyCloneFromRow(query, joinManager, databaseRow, unitOfWork, primaryKey, preFetchedCacheKey); } } return buildWorkingCopyCloneNormally(query, databaseRow, unitOfWork, primaryKey, preFetchedCacheKey, concreteDescriptor, joinManager); }
/** * For executing all reads on the UnitOfWork, the session when building * objects from rows will now be the UnitOfWork. Useful if the rows were * read via a dirty write connection and we want to avoid putting uncommitted * data in the global cache. * <p> * Decides whether to call either buildWorkingCopyCloneFromRow (bypassing * shared cache) or buildWorkingCopyCloneNormally (placing the result in the * shared cache). */ protected Object buildObjectInUnitOfWork(ObjectBuildingQuery query, JoinedAttributeManager joinManager, AbstractRecord databaseRow, UnitOfWorkImpl unitOfWork, Object primaryKey, CacheKey preFetchedCacheKey, ClassDescriptor concreteDescriptor) throws DatabaseException, QueryException { // When in transaction we are reading via the write connection // and so do not want to corrupt the shared cache with dirty objects. // Hence we build and refresh clones directly from the database row. // PERF: Allow the session cached to still be used after early transaction if isolation setting has been set. CachePolicy cachePolicy = concreteDescriptor.getCachePolicy(); if (!cachePolicy.shouldUseSessionCacheInUnitOfWorkEarlyTransaction()) { if (((unitOfWork.hasCommitManager() && unitOfWork.getCommitManager().isActive()) || unitOfWork.wasTransactionBegunPrematurely() || cachePolicy.shouldIsolateObjectsInUnitOfWork() || cachePolicy.shouldIsolateProtectedObjectsInUnitOfWork() || query.shouldStoreBypassCache()) && (!unitOfWork.isClassReadOnly(concreteDescriptor.getJavaClass(), concreteDescriptor))) { // It is easier to switch once to the correct builder here. return concreteDescriptor.getObjectBuilder().buildWorkingCopyCloneFromRow(query, joinManager, databaseRow, unitOfWork, primaryKey, preFetchedCacheKey); } } return buildWorkingCopyCloneNormally(query, databaseRow, unitOfWork, primaryKey, preFetchedCacheKey, concreteDescriptor, joinManager); }
try { if (query.shouldMaintainCache() && (!query.shouldRetrieveBypassCache() || !query.shouldStoreBypassCache())) { cacheKey = session.retrieveCacheKey(primaryKey, concreteDescriptor, joinManager, query); protectedObject = cacheKey.getObject(); cacheHit = false; boolean domainWasMissing = protectedObject == null; if (protectedObject == null || query.shouldStoreBypassCache()){ if (query.isReadObjectQuery() && ((ReadObjectQuery)query).shouldLoadResultIntoSelectionObject()) { protectedObject = ((ReadObjectQuery)query).getSelectionObject(); if (query.shouldMaintainCache() && ! query.shouldStoreBypassCache()){ if (domainWasMissing) { // may have build a new domain even though there is one in the cache cacheKey.setObject(protectedObject); if (query.shouldMaintainCache() && ! query.shouldStoreBypassCache()) { if (preFetchedCacheKey == null){ sharedCacheKey = session.getParent().retrieveCacheKey(primaryKey, concreteDescriptor, joinManager, query); if (query.shouldMaintainCache() && ! query.shouldStoreBypassCache()) {
try { if (query.shouldMaintainCache() && (!query.shouldRetrieveBypassCache() || !query.shouldStoreBypassCache())) { cacheKey = session.retrieveCacheKey(primaryKey, concreteDescriptor, joinManager, query); protectedObject = cacheKey.getObject(); cacheHit = false; boolean domainWasMissing = protectedObject == null; if (protectedObject == null || query.shouldStoreBypassCache()){ if (query.isReadObjectQuery() && ((ReadObjectQuery)query).shouldLoadResultIntoSelectionObject()) { protectedObject = ((ReadObjectQuery)query).getSelectionObject(); if (query.shouldMaintainCache() && ! query.shouldStoreBypassCache()){ if (domainWasMissing) { // may have build a new domain even though there is one in the cache cacheKey.setObject(protectedObject); if (query.shouldMaintainCache() && ! query.shouldStoreBypassCache()) { if (preFetchedCacheKey == null){ sharedCacheKey = session.getParent().retrieveCacheKey(primaryKey, concreteDescriptor, joinManager, query); if (query.shouldMaintainCache() && ! query.shouldStoreBypassCache()) {
if (wasAnOriginal && query.shouldStoreBypassCache()) { workingClone = instantiateWorkingCopyClone(original, unitOfWork);
if (query.shouldMaintainCache() && ! query.shouldStoreBypassCache()) { cacheKey.setObject(domainObject); copyQueryInfoToCacheKey(cacheKey, query, databaseRow, session, concreteDescriptor); if (query.shouldMaintainCache() && ! query.shouldStoreBypassCache()) {
&& !refreshing && sourceQuery.shouldMaintainCache() && !sourceQuery.shouldStoreBypassCache()) {
&& sourceQuery.shouldMaintainCache() && !sourceQuery.shouldStoreBypassCache()) {
fetchGroupManager.setObjectFetchGroup(workingClone, query.getExecutionFetchGroup(this.descriptor), unitOfWork); if (!unitOfWork.wasTransactionBegunPrematurely() && descriptor.getCachePolicy().isProtectedIsolation() && !isIsolated && !query.shouldStoreBypassCache()) {
if (!unitOfWork.wasTransactionBegunPrematurely() && descriptor.getCachePolicy().isProtectedIsolation() && !isIsolated && !query.shouldStoreBypassCache()) {
try { boolean shouldRetrieveBypassCache = query.shouldRetrieveBypassCache(); boolean shouldStoreBypassCache = query.shouldStoreBypassCache();
try { boolean shouldRetrieveBypassCache = query.shouldRetrieveBypassCache(); boolean shouldStoreBypassCache = query.shouldStoreBypassCache();