/** * INTERNAL: * The mapping is initialized with the given session. */ @Override public void initialize(AbstractSession session) throws DescriptorException { super.initialize(session); initializeAttributeTransformer(session); initializeFieldToTransformers(session); setFields(collectFields()); this.indirectionPolicy.initialize(); if (usesIndirection()) { for (DatabaseField field : this.fields) { field.setKeepInRow(true); } } }
/** * INTERNAL: * The mapping is initialized with the given session. */ @Override public void initialize(AbstractSession session) throws DescriptorException { super.initialize(session); initializeAttributeTransformer(session); initializeFieldToTransformers(session); setFields(collectFields()); this.indirectionPolicy.initialize(); if (usesIndirection()) { for (DatabaseField field : this.fields) { field.setKeepInRow(true); } } }
/** * INTERNAL: * Extract value from the row and set the attribute to this value in the * working copy clone. * In order to bypass the shared cache when in transaction a UnitOfWork must * be able to populate working copies directly from the row. */ @Override public void buildCloneFromRow(AbstractRecord record, JoinedAttributeManager joinManager, Object clone, CacheKey sharedCacheKey, ObjectBuildingQuery sourceQuery, UnitOfWorkImpl unitOfWork, AbstractSession executionSession) { // If mapping is a no-attribute transformation mapping, do nothing if (isWriteOnly()) { return; } // This will set the value in the clone automatically. Object attributeValue = readFromRowIntoObject(record, joinManager, clone, sharedCacheKey, sourceQuery, executionSession, true); if (usesIndirection()) { boolean wasCacheUsed = this.isCacheable && sharedCacheKey != null && this.descriptor.getCachePolicy().isProtectedIsolation() && sharedCacheKey.getObject() != null; //it would be better if wasCacheUsed could be calculated within readFromRowIntoObject but that would require changing the signature of all mappings just for //transformation mapping. if (!wasCacheUsed){ //if the cache was used then the attribute has already been cloned by readFromRowIntoObject attributeValue = this.indirectionPolicy.cloneAttribute(attributeValue, null,// no original null, clone, null, unitOfWork, true);// build clone directly from row. } setAttributeValueInObject(clone, attributeValue); } }
/** * INTERNAL: * Extract value from the row and set the attribute to this value in the * working copy clone. * In order to bypass the shared cache when in transaction a UnitOfWork must * be able to populate working copies directly from the row. */ @Override public void buildCloneFromRow(AbstractRecord record, JoinedAttributeManager joinManager, Object clone, CacheKey sharedCacheKey, ObjectBuildingQuery sourceQuery, UnitOfWorkImpl unitOfWork, AbstractSession executionSession) { // If mapping is a no-attribute transformation mapping, do nothing if (isWriteOnly()) { return; } // This will set the value in the clone automatically. Object attributeValue = readFromRowIntoObject(record, joinManager, clone, sharedCacheKey, sourceQuery, executionSession, true); if (usesIndirection()) { boolean wasCacheUsed = this.isCacheable && sharedCacheKey != null && this.descriptor.getCachePolicy().isProtectedIsolation() && sharedCacheKey.getObject() != null; //it would be better if wasCacheUsed could be calculated within readFromRowIntoObject but that would require changing the signature of all mappings just for //transformation mapping. if (!wasCacheUsed){ //if the cache was used then the attribute has already been cloned by readFromRowIntoObject attributeValue = this.indirectionPolicy.cloneAttribute(attributeValue, null,// no original null, clone, null, unitOfWork, true);// build clone directly from row. } setAttributeValueInObject(clone, attributeValue); } }
if (transMapping.usesIndirection()) { allAttributesNull = transMapping.getIndirectionPolicy().objectIsInstantiated(baseValue);
if (mergeManager.shouldRefreshRemoteObject() && usesIndirection()) { getIndirectionPolicy().mergeRemoteValueHolder(target, source, mergeManager); return;
if (transMapping.usesIndirection()) { allAttributesNull = transMapping.getIndirectionPolicy().objectIsInstantiated(baseValue);
if (mergeManager.shouldRefreshRemoteObject() && usesIndirection()) { this.indirectionPolicy.mergeRemoteValueHolder(target, source, mergeManager); return;
if (mergeManager.shouldRefreshRemoteObject() && usesIndirection()) { this.indirectionPolicy.mergeRemoteValueHolder(target, source, mergeManager); return;
if (transMapping.usesIndirection()) { allAttributesNull = transMapping.getIndirectionPolicy().objectIsInstantiated(baseValue);