/** * INTERNAL: */ @Override public String toString() { return getClass().getName() + "[" + getAttributeName() + "-->" + getField() + "]"; }
/** * INTERNAL: */ public String toString() { return getClass().getName() + "[" + getAttributeName() + "-->" + getField() + "]"; }
/** * INTERNAL: */ @Override public String toString() { return getClass().getName() + "[" + getAttributeName() + "-->" + getField() + "]"; }
/** * INTERNAL: * Build a change record */ public ChangeRecord internalBuildChangeRecord(Object newValue, ObjectChangeSet owner) { DirectToFieldChangeRecord changeRecord = new DirectToFieldChangeRecord(owner); changeRecord.setAttribute(getAttributeName()); changeRecord.setMapping(this); changeRecord.setNewValue(newValue); return changeRecord; }
/** * INTERNAL: * In case Query By Example is used, this method builds and returns an expression that * corresponds to a single attribute and it's value for a directToField mapping. */ public Expression buildExpression(Object queryObject, QueryByExamplePolicy policy, Expression expressionBuilder, Map processedObjects, AbstractSession session) { String attributeName = this.getAttributeName(); Object attributeValue = this.getAttributeValueFromObject(queryObject); if (!policy.shouldIncludeInQuery(queryObject.getClass(), attributeName, attributeValue)) { //the attribute name and value pair is not to be included in the query. return null; } Expression expression = expressionBuilder.get(attributeName); if (attributeValue == null) { expression = policy.completeExpressionForNull(expression); } else { expression = policy.completeExpression(expression, attributeValue, attributeValue.getClass()); } return expression; }
/** * INTERNAL: * Either create a new change record or update with the new value. This is used * by attribute change tracking. */ public void updateChangeRecord(Object clone, Object newValue, Object oldValue, ObjectChangeSet objectChangeSet, UnitOfWorkImpl uow) { DirectToFieldChangeRecord changeRecord = (DirectToFieldChangeRecord)objectChangeSet.getChangesForAttributeNamed(this.getAttributeName()); if (changeRecord == null) { objectChangeSet.addChange(internalBuildChangeRecord(newValue, objectChangeSet)); } else { changeRecord.setNewValue(newValue); } }
/** * INTERNAL: * Either create a new change record or update with the new value. This is used * by attribute change tracking. */ @Override public void updateChangeRecord(Object clone, Object newValue, Object oldValue, ObjectChangeSet objectChangeSet, UnitOfWorkImpl uow) { DirectToFieldChangeRecord changeRecord = (DirectToFieldChangeRecord)objectChangeSet.getChangesForAttributeNamed(this.getAttributeName()); if (changeRecord == null) { objectChangeSet.addChange(internalBuildChangeRecord(newValue, oldValue, objectChangeSet)); } else { changeRecord.setNewValue(newValue); } }
/** * INTERNAL: * In case Query By Example is used, this method builds and returns an expression that * corresponds to a single attribute and it's value for a directToField mapping. */ @Override public Expression buildExpression(Object queryObject, QueryByExamplePolicy policy, Expression expressionBuilder, Map processedObjects, AbstractSession session) { String attributeName = this.getAttributeName(); Object attributeValue = this.getAttributeValueFromObject(queryObject); if (!policy.shouldIncludeInQuery(queryObject.getClass(), attributeName, attributeValue)) { //the attribute name and value pair is not to be included in the query. return null; } Expression expression = expressionBuilder.get(attributeName); if (attributeValue == null) { expression = policy.completeExpressionForNull(expression); } else { expression = policy.completeExpression(expression, attributeValue, attributeValue.getClass()); } return expression; }
/** * INTERNAL: * Either create a new change record or update with the new value. This is used * by attribute change tracking. */ @Override public void updateChangeRecord(Object clone, Object newValue, Object oldValue, ObjectChangeSet objectChangeSet, UnitOfWorkImpl uow) { DirectToFieldChangeRecord changeRecord = (DirectToFieldChangeRecord)objectChangeSet.getChangesForAttributeNamed(this.getAttributeName()); if (changeRecord == null) { objectChangeSet.addChange(internalBuildChangeRecord(newValue, oldValue, objectChangeSet)); } else { changeRecord.setNewValue(newValue); } }
/** * INTERNAL: * In case Query By Example is used, this method builds and returns an expression that * corresponds to a single attribute and it's value for a directToField mapping. */ @Override public Expression buildExpression(Object queryObject, QueryByExamplePolicy policy, Expression expressionBuilder, Map processedObjects, AbstractSession session) { String attributeName = this.getAttributeName(); Object attributeValue = this.getAttributeValueFromObject(queryObject); if (!policy.shouldIncludeInQuery(queryObject.getClass(), attributeName, attributeValue)) { //the attribute name and value pair is not to be included in the query. return null; } Expression expression = expressionBuilder.get(attributeName); if (attributeValue == null) { expression = policy.completeExpressionForNull(expression); } else { expression = policy.completeExpression(expression, attributeValue, attributeValue.getClass()); } return expression; }
/** * INTERNAL: * Build a change record. */ public ChangeRecord internalBuildChangeRecord(Object newValue, Object oldValue, ObjectChangeSet owner) { DirectToFieldChangeRecord changeRecord = new DirectToFieldChangeRecord(owner); changeRecord.setAttribute(getAttributeName()); changeRecord.setMapping(this); changeRecord.setNewValue(newValue); changeRecord.setOldValue(oldValue); return changeRecord; }
/** * INTERNAL: * Build a change record. */ public ChangeRecord internalBuildChangeRecord(Object newValue, Object oldValue, ObjectChangeSet owner) { DirectToFieldChangeRecord changeRecord = new DirectToFieldChangeRecord(owner); changeRecord.setAttribute(getAttributeName()); changeRecord.setMapping(this); changeRecord.setNewValue(newValue); changeRecord.setOldValue(oldValue); return changeRecord; }
/** * INTERNAL: * Merge changes from the source to the target object. This merge is only called when a changeSet for the target * does not exist or the target is uninitialized */ public void mergeIntoObject(Object target, boolean isTargetUnInitialized, Object source, MergeManager mergeManager) { // If merge into the unit of work, must only merge and raise the event is the value changed. if ((mergeManager.shouldMergeCloneIntoWorkingCopy() || mergeManager.shouldMergeCloneWithReferencesIntoWorkingCopy()) && this.descriptor.getObjectChangePolicy().isObjectChangeTrackingPolicy()) { // if it didn't change then there will be no event Object attributeValue = getAttributeValueFromObject(source); Object targetAttribute = getAttributeValueFromObject(target); if (!compareObjectValues(attributeValue, targetAttribute, mergeManager.getSession())) { setAttributeValueInObject(target, buildCloneValue(attributeValue, mergeManager.getSession())); //set the value first, if the owner is new ( or aggregate) the change set may be created directly //from the target. this.descriptor.getObjectChangePolicy().raiseInternalPropertyChangeEvent(target, getAttributeName(), targetAttribute, attributeValue); } } else { setAttributeValueInObject(target, buildCloneValue(getAttributeValueFromObject(source), mergeManager.getSession())); } }
/** * INTERNAL: * Merge changes from the source to the target object. This merge is only called when a changeSet for the target * does not exist or the target is uninitialized */ @Override public void mergeIntoObject(Object target, boolean isTargetUnInitialized, Object source, MergeManager mergeManager, AbstractSession targetSession) { // If merge into the unit of work, must only merge and raise the event is the value changed. if ((mergeManager.shouldMergeCloneIntoWorkingCopy() || mergeManager.shouldMergeCloneWithReferencesIntoWorkingCopy()) && !mergeManager.isForRefresh() && this.descriptor.getObjectChangePolicy().isObjectChangeTrackingPolicy()) { // if it didn't change then there will be no event Object attributeValue = getAttributeValueFromObject(source); Object targetAttribute = getAttributeValueFromObject(target); if (!compareObjectValues(attributeValue, targetAttribute, mergeManager.getSession())) { setAttributeValueInObject(target, buildCloneValue(attributeValue, mergeManager.getSession())); //set the value first, if the owner is new ( or aggregate) the change set may be created directly //from the target. this.descriptor.getObjectChangePolicy().raiseInternalPropertyChangeEvent(target, getAttributeName(), targetAttribute, attributeValue); } } else { setAttributeValueInObject(target, buildCloneValue(getAttributeValueFromObject(source), mergeManager.getSession())); } }
/** * INTERNAL: * Merge changes from the source to the target object. This merge is only called when a changeSet for the target * does not exist or the target is uninitialized */ @Override public void mergeIntoObject(Object target, boolean isTargetUnInitialized, Object source, MergeManager mergeManager, AbstractSession targetSession) { // If merge into the unit of work, must only merge and raise the event is the value changed. if ((mergeManager.shouldMergeCloneIntoWorkingCopy() || mergeManager.shouldMergeCloneWithReferencesIntoWorkingCopy()) && !mergeManager.isForRefresh() && this.descriptor.getObjectChangePolicy().isObjectChangeTrackingPolicy()) { // if it didn't change then there will be no event Object attributeValue = getAttributeValueFromObject(source); Object targetAttribute = getAttributeValueFromObject(target); if (!compareObjectValues(attributeValue, targetAttribute, mergeManager.getSession())) { setAttributeValueInObject(target, buildCloneValue(attributeValue, mergeManager.getSession())); //set the value first, if the owner is new ( or aggregate) the change set may be created directly //from the target. this.descriptor.getObjectChangePolicy().raiseInternalPropertyChangeEvent(target, getAttributeName(), targetAttribute, attributeValue); } } else { setAttributeValueInObject(target, buildCloneValue(getAttributeValueFromObject(source), mergeManager.getSession())); } }
changeRecord.setAttribute(this.lockMapping.getAttributeName()); changeRecord.setMapping(this.lockMapping); changeRecord.setNewValue(convertedLockValue);
changeRecord.setAttribute(this.lockMapping.getAttributeName()); changeRecord.setMapping(this.lockMapping); changeRecord.setNewValue(convertedLockValue);
if (this.sequenceMapping != null) { String attributeName = this.sequenceMapping.getAttributeName(); DirectToFieldChangeRecord changeRecord = (DirectToFieldChangeRecord)objectChangeSet.getChangesForAttributeNamed(attributeName); if (changeRecord == null) {
if (this.sequenceMapping != null) { String attributeName = this.sequenceMapping.getAttributeName(); DirectToFieldChangeRecord changeRecord = (DirectToFieldChangeRecord)objectChangeSet.getChangesForAttributeNamed(attributeName); if (changeRecord == null) {