blob: 7620a68ce6617bf37594345acaf3728f4b9902e9 [file] [log] [blame]
/*
* Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
// Contributors:
// Oracle - initial API and implementation from Oracle TopLink
package org.eclipse.persistence.internal.sessions;
import org.eclipse.persistence.sessions.DataRecord;
import org.eclipse.persistence.sessions.DatabaseRecord;
/**
* <p>
* <b>Purpose</b>: To record the changes for attributes that can be represented as Transformation Mapping
* </p>
*/
public class TransformationMappingChangeRecord extends ChangeRecord implements org.eclipse.persistence.sessions.changesets.TransformationMappingChangeRecord {
protected AbstractRecord rowCollection;
protected transient Object oldValue;
/**
* This default constructor.
*/
public TransformationMappingChangeRecord() {
super();
}
/**
* This is the basic constructor for this change Record.
* This change record stores the fields that have changed as that is our current method of comparing
* changes.
*/
public TransformationMappingChangeRecord(ObjectChangeSet owner) {
this.owner = owner;
}
/**
* ADVANCED:
* This method is used to access the changes of the fields in a transformation mapping.
*/
@Override
public DataRecord getRecord() {
if (rowCollection == null) {
this.rowCollection = new DatabaseRecord();
}
return rowCollection;
}
/**
* INTERNAL:
* This method will be used to merge one record into another
*/
@Override
public void mergeRecord(ChangeRecord mergeFromRecord, UnitOfWorkChangeSet mergeToChangeSet, UnitOfWorkChangeSet mergeFromChangeSet) {
this.rowCollection = (AbstractRecord)((TransformationMappingChangeRecord)mergeFromRecord).getRecord();
}
/**
* This method is used to add a changed value to the changeRecord. The changes in a transformation
* mapping are recorded on the database field level
* @param record Record the values from the transformation mapping
*/
public void setRow(AbstractRecord record) {
this.rowCollection = record;
}
/**
* INTERNAL:
* This method will be used to update the objectsChangeSets references
* There is nothing to do for this mapping type as there are no object
* references
*/
@Override
public void updateReferences(UnitOfWorkChangeSet mergeToChangeSet, UnitOfWorkChangeSet mergeFromChangeSet) {
}
/**
* ADVANCED:
* Return the old value of the attribute represented by this ChangeRecord.
*/
@Override
public Object getOldValue() {
return this.oldValue;
}
/**
* INTERNAL:
* Set the old value of the attribute represented by this ChangeRecord.
*/
public void setOldValue(Object oldValue) {
this.oldValue = oldValue;
}
}