Methods Summary |
---|
public void | addReferenceKeyField(oracle.toplink.essentials.internal.helper.DatabaseField referenceForeignKeyField, oracle.toplink.essentials.internal.helper.DatabaseField sourcePrimaryKeyField)PUBLIC:
Add the reference key field.
This is used for composite reference keys.
This is the foreign key field in the direct table referencing the primary key of the source object.
Both the reference field and the source field that it references must be provided.
getSourceKeyFields().addElement(sourcePrimaryKeyField);
getReferenceKeyFields().addElement(referenceForeignKeyField);
|
public void | addReferenceKeyFieldName(java.lang.String referenceForeignKeyFieldName, java.lang.String sourcePrimaryKeyFieldName)PUBLIC:
Add the name of the reference key field.
This is used for composite reference keys.
This is the foreign key field in the direct table referencing the primary key of the source object.
Both the reference field name and the name of the source field that it references must be provided.
addReferenceKeyField(new DatabaseField(referenceForeignKeyFieldName), new DatabaseField(sourcePrimaryKeyFieldName));
|
public void | addToCollectionChangeRecord(java.lang.Object newKey, java.lang.Object newValue, oracle.toplink.essentials.internal.sessions.ObjectChangeSet objectChangeSet, oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl uow)INTERNAL:
Add a new value and its change set to the collection change record. This is used by
attribute change tracking.
if (newValue == null) {
newValue = DirectCollectionChangeRecord.Null;
}
ClassDescriptor descriptor;
DirectCollectionChangeRecord collectionChangeRecord = (DirectCollectionChangeRecord)objectChangeSet.getChangesForAttributeNamed(this.getAttributeName());
if (collectionChangeRecord == null) {
collectionChangeRecord = new DirectCollectionChangeRecord(objectChangeSet);
collectionChangeRecord.setAttribute(getAttributeName());
collectionChangeRecord.setMapping(this);
objectChangeSet.addChange(collectionChangeRecord);
Object collection = getRealAttributeValueFromObject(objectChangeSet.getUnitOfWorkClone(), uow);
collectionChangeRecord.storeDatabaseCounts(collection, getContainerPolicy(), uow);
}
collectionChangeRecord.addAdditionChange(newValue, new Integer(1));
|
public void | buildCopy(java.lang.Object copy, java.lang.Object original, oracle.toplink.essentials.sessions.ObjectCopyingPolicy policy)INTERNAL:
Copy of the attribute of the object.
This is NOT used for unit of work but for templatizing an object.
Object attributeValue = getRealCollectionAttributeValueFromObject(original, policy.getSession());
attributeValue = getContainerPolicy().cloneFor(attributeValue);
setRealAttributeValueInObject(copy, attributeValue);
|
protected java.lang.Object | buildElementClone(java.lang.Object element, oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl unitOfWork, boolean isExisting)INTERNAL:
Clone the element, if necessary.
DirectCollections hold on to objects that do not have Descriptors
(e.g. int, String). These objects do not need to be cloned, unless they use a converter - they
are immutable.
Object cloneValue = element;
if ((getValueConverter() != null) && getValueConverter().isMutable()) {
cloneValue = getValueConverter().convertDataValueToObjectValue(getValueConverter().convertObjectValueToDataValue(cloneValue, unitOfWork), unitOfWork);
}
return cloneValue;
|
public void | calculateDeferredChanges(oracle.toplink.essentials.internal.sessions.ChangeRecord changeRecord, oracle.toplink.essentials.internal.sessions.AbstractSession session)INTERNAL:
Used by AttributeLevelChangeTracking to update a changeRecord with calculated changes
as apposed to detected changes. If an attribute can not be change tracked it's
changes can be detected through this process.
DirectCollectionChangeRecord collectionRecord = (DirectCollectionChangeRecord) changeRecord;
compareCollectionsForChange(collectionRecord.getOriginalCollection(), collectionRecord.getLatestCollection(), collectionRecord, session);
|
public void | cascadePerformRemoveIfRequired(java.lang.Object object, oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl uow, oracle.toplink.essentials.internal.helper.IdentityHashtable visitedObjects)INTERNAL:
Cascade perform delete through mappings that require the cascade
//as this mapping type references primitive objects this method does not apply
|
public void | cascadeRegisterNewIfRequired(java.lang.Object object, oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl uow, oracle.toplink.essentials.internal.helper.IdentityHashtable visitedObjects)INTERNAL:
Cascade registerNew for Create through mappings that require the cascade
//as this mapping type references primitive objects this method does not apply
|
public java.lang.Object | clone()INTERNAL:
The mapping clones itself to create deep copy.
DirectCollectionMapping clone = (DirectCollectionMapping)super.clone();
clone.setSourceKeyFields(cloneFields(getSourceKeyFields()));
clone.setReferenceKeyFields(cloneFields(getReferenceKeyFields()));
return clone;
|
public void | compareCollectionsForChange(java.lang.Object oldCollection, java.lang.Object newCollection, oracle.toplink.essentials.internal.sessions.ChangeRecord changeRecord, oracle.toplink.essentials.internal.sessions.AbstractSession session)INTERNAL:
This method is used to calculate the differences between two collections.
ContainerPolicy cp = getContainerPolicy();
int numberOfNewNulls = 0;
HashMap originalKeyValues = new HashMap(10);
HashMap cloneKeyValues = new HashMap(10);
if (oldCollection != null){
Object backUpIter = cp.iteratorFor(oldCollection);
while (cp.hasNext(backUpIter)) {// Make a lookup of the objects
Object secondObject = cp.next(backUpIter, session);
// For CR#2258/CR#2378 handle null values inserted in a collection.
if (secondObject == null) {
numberOfNewNulls--;
} else {
Integer count = (Integer)originalKeyValues.get(secondObject);
if (count == null) {
originalKeyValues.put(secondObject, new Integer(1));
} else {
originalKeyValues.put(secondObject, new Integer(count.intValue() + 1));
}
}
}
}
// should a removal occur this is the original count of objects on the database.
// this value is used to determine how many objects to re-insert after the delete as a
// delete will delete all of the objects not just one.
HashMap databaseCount = (HashMap)originalKeyValues.clone();
int databaseNullCount = Math.abs(numberOfNewNulls);
if (newCollection != null){
Object cloneIter = cp.iteratorFor(newCollection);
/* The following code is used to compare objects in a direct collection.
Because objects in a direct collection are primitives and may be the same object
the following code must count the number of instances in the collection not just the
existence of an object.
*/
while (cp.hasNext(cloneIter)) {//Compare them with the objects from the clone
Object firstObject = cp.next(cloneIter, session);
// For CR#2258/CR#2378 handle null values inserted in a collection.
if (firstObject == null) {
numberOfNewNulls++;
} else {
Integer count = (Integer)originalKeyValues.get(firstObject);
if (count == null) {//the object was not in the backup
Integer cloneCount = (Integer)cloneKeyValues.get(firstObject);
//Add it to the additions hashtable
if (cloneCount == null) {
cloneKeyValues.put(firstObject, new Integer(1));
} else {
cloneKeyValues.put(firstObject, new Integer(cloneCount.intValue() + 1));
}
} else if (count.intValue() == 1) {
//There is only one object so remove the whole reference
originalKeyValues.remove(firstObject);
} else {
originalKeyValues.put(firstObject, new Integer(count.intValue() - 1));
}
}
}
}
if (cloneKeyValues.isEmpty() && originalKeyValues.isEmpty() && (numberOfNewNulls == 0) && (!changeRecord.getOwner().isNew())) {
return;
}
((DirectCollectionChangeRecord)changeRecord).addAdditionChange(cloneKeyValues, databaseCount);
((DirectCollectionChangeRecord)changeRecord).addRemoveChange(originalKeyValues, databaseCount);
//For CR#2258, produce a changeRecord which reflects the addition and removal of null values.
if (numberOfNewNulls != 0) {
Vector changeList = null;
((DirectCollectionChangeRecord)changeRecord).getCommitAddMap().put(DirectCollectionChangeRecord.Null, new Integer(databaseNullCount));
if (numberOfNewNulls > 0) {
((DirectCollectionChangeRecord)changeRecord).addAdditionChange(DirectCollectionChangeRecord.Null, new Integer(numberOfNewNulls));
} else {
numberOfNewNulls *= -1;
((DirectCollectionChangeRecord)changeRecord).addRemoveChange(DirectCollectionChangeRecord.Null, new Integer(numberOfNewNulls));
}
}
|
public oracle.toplink.essentials.internal.sessions.ChangeRecord | compareForChange(java.lang.Object clone, java.lang.Object backUp, oracle.toplink.essentials.internal.sessions.ObjectChangeSet owner, oracle.toplink.essentials.internal.sessions.AbstractSession session)INTERNAL:
This method compares the changes between two direct collections. Comparisons are made on equality
not identity.
Object cloneAttribute = null;
Object backUpAttribute = null;
int numberOfNewNulls = 0;
ContainerPolicy cp = getContainerPolicy();
cloneAttribute = getAttributeValueFromObject(clone);
if ((cloneAttribute != null) && (!getIndirectionPolicy().objectIsInstantiated(cloneAttribute))) {
return null;
}
Object cloneObjectCollection = getRealCollectionAttributeValueFromObject(clone, session);
Object backUpCollection = null;
if (!owner.isNew()) {
backUpAttribute = getAttributeValueFromObject(backUp);
if ((backUpAttribute == null) && (cloneAttribute == null)) {
return null;
}
backUpCollection = getRealCollectionAttributeValueFromObject(backUp, session);
}
DirectCollectionChangeRecord changeRecord = new DirectCollectionChangeRecord(owner);
changeRecord.setAttribute(getAttributeName());
changeRecord.setMapping(this);
compareCollectionsForChange(backUpCollection, cloneObjectCollection, changeRecord, session);
if (changeRecord.hasChanges()){
return changeRecord;
}
return null;
|
public boolean | compareObjects(java.lang.Object firstObject, java.lang.Object secondObject, oracle.toplink.essentials.internal.sessions.AbstractSession session)INTERNAL:
Compare the attributes belonging to this mapping for the objects.
Object firstCollection = getRealCollectionAttributeValueFromObject(firstObject, session);
Object secondCollection = getRealCollectionAttributeValueFromObject(secondObject, session);
ContainerPolicy containerPolicy = getContainerPolicy();
if (containerPolicy.sizeFor(firstCollection) != containerPolicy.sizeFor(secondCollection)) {
return false;
}
HashMap firstCounter = new HashMap();
HashMap secondCounter = new HashMap();
for (Object iter = containerPolicy.iteratorFor(firstCollection);containerPolicy.hasNext(iter);) {
Object object = containerPolicy.next(iter, session);
if (firstCounter.containsKey(object)){
int count = ((Integer)firstCounter.get(object)).intValue();
firstCounter.put(object, new Integer(++count));
}else{
firstCounter.put(object, new Integer(1));
}
}
for (Object iter = containerPolicy.iteratorFor(secondCollection);containerPolicy.hasNext(iter);) {
Object object = containerPolicy.next(iter, session);
if (secondCounter.containsKey(object)){
int count = ((Integer)secondCounter.get(object)).intValue();
secondCounter.put(object, new Integer(++count));
}else{
secondCounter.put(object, new Integer(1));
}
}
for (Iterator iterator = firstCounter.keySet().iterator(); iterator.hasNext();){
Object object = iterator.next();
if (!secondCounter.containsKey(object) || ( ((Integer)secondCounter.get(object)).intValue() != ((Integer)firstCounter.get(object)).intValue()) ) {
return false;
}else{
iterator.remove();
secondCounter.remove(object);
}
}
if ( !firstCounter.isEmpty() || !secondCounter.isEmpty() ) {
return false;
}
return true;
|
public void | convertClassNamesToClasses(java.lang.ClassLoader classLoader)INTERNAL:
Convert all the class-name-based settings in this mapping to actual class-based
settings
This method is implemented by subclasses as necessary.
super.convertClassNamesToClasses(classLoader);
if (valueConverter != null) {
if (valueConverter instanceof TypeConversionConverter){
((TypeConversionConverter)valueConverter).convertClassNamesToClasses(classLoader);
} else if (valueConverter instanceof ObjectTypeConverter) {
// To avoid 1.5 dependencies with the EnumTypeConverter check
// against ObjectTypeConverter.
((ObjectTypeConverter) valueConverter).convertClassNamesToClasses(classLoader);
}
}
|
protected java.util.Vector | extractKeyFromReferenceRow(oracle.toplink.essentials.internal.sessions.AbstractRecord row, oracle.toplink.essentials.internal.sessions.AbstractSession session)INTERNAL:
Extract the source primary key value from the reference direct row.
Used for batch reading, most following same order and fields as in the mapping.
Vector key = new Vector(getReferenceKeyFields().size());
for (int index = 0; index < getReferenceKeyFields().size(); index++) {
DatabaseField relationField = (DatabaseField)getReferenceKeyFields().elementAt(index);
DatabaseField sourceField = (DatabaseField)getSourceKeyFields().elementAt(index);
Object value = row.get(relationField);
// Must ensure the classificatin to get a cache hit.
try {
value = session.getDatasourcePlatform().getConversionManager().convertObject(value, getDescriptor().getObjectBuilder().getFieldClassification(sourceField));
} catch (ConversionException e) {
throw ConversionException.couldNotBeConverted(this, getDescriptor(), e);
}
key.addElement(value);
}
return key;
|
protected java.util.Vector | extractPrimaryKeyFromRow(oracle.toplink.essentials.internal.sessions.AbstractRecord row, oracle.toplink.essentials.internal.sessions.AbstractSession session)INTERNAL:
Extract the primary key value from the source row.
Used for batch reading, most following same order and fields as in the mapping.
Vector key = new Vector(getSourceKeyFields().size());
for (Enumeration fieldEnum = getSourceKeyFields().elements(); fieldEnum.hasMoreElements();) {
DatabaseField field = (DatabaseField)fieldEnum.nextElement();
Object value = row.get(field);
// Must ensure the classificatin to get a cache hit.
try {
value = session.getDatasourcePlatform().getConversionManager().convertObject(value, getDescriptor().getObjectBuilder().getFieldClassification(field));
} catch (ConversionException e) {
throw ConversionException.couldNotBeConverted(this, getDescriptor(), e);
}
key.addElement(value);
}
return key;
|
protected oracle.toplink.essentials.queryframework.ModifyQuery | getDeleteQuery()
if (changeSetDeleteQuery == null) {
changeSetDeleteQuery = new DataModifyQuery();
}
return changeSetDeleteQuery;
|
public oracle.toplink.essentials.internal.helper.DatabaseField | getDirectField()INTERNAL:
Return the direct field.
This is the field in the direct table to store the values.
return directField;
|
public java.lang.String | getDirectFieldName()PUBLIC:
Returns the name of the field name in the reference table.
if (getDirectField() == null) {
return null;
}
return getDirectField().getQualifiedName();
|
protected oracle.toplink.essentials.queryframework.DataModifyQuery | getInsertQuery()
return insertQuery;
|
public java.lang.Class | getReferenceClass()INTERNAL:
This cannot be used with direct collection mappings.
return null;
|
public java.lang.String | getReferenceClassName()
return null;
|
public oracle.toplink.essentials.descriptors.ClassDescriptor | getReferenceDescriptor()INTERNAL:
There is none on direct collection.
return null;
|
public java.util.Vector | getReferenceKeyFieldNames()INTERNAL:
Return the reference key field names associated with the mapping.
These are in-order with the sourceKeyFieldNames.
Vector fieldNames = new Vector(getReferenceKeyFields().size());
for (Enumeration fieldsEnum = getReferenceKeyFields().elements();
fieldsEnum.hasMoreElements();) {
fieldNames.addElement(((DatabaseField)fieldsEnum.nextElement()).getQualifiedName());
}
return fieldNames;
|
public java.util.Vector | getReferenceKeyFields()INTERNAL:
Return the reference key fields.
return referenceKeyFields;
|
public oracle.toplink.essentials.internal.helper.DatabaseTable | getReferenceTable()INTERNAL:
Return the direct table.
This is the table to store the values.
return referenceTable;
|
public java.lang.String | getReferenceTableName()PUBLIC:
Returns the name of the reference table
if (getReferenceTable() == null) {
return null;
}
return getReferenceTable().getName();
|
public java.lang.String | getReferenceTableQualifiedName()PUBLIC:
Returns the qualified name of the reference table//CR#2407
if (getReferenceTable() == null) {
return null;
}
return getReferenceTable().getQualifiedName();
|
public oracle.toplink.essentials.mappings.DatabaseMapping | getRelationshipPartner()INTERNAL:
Return the relationshipPartner mapping for this bi-directional mapping. If the relationshipPartner is null then
this is a uni-directional mapping.
DirectCollectionMapping can not be part of a bi-directional mapping
return null;
|
public java.util.Vector | getSourceKeyFieldNames()PUBLIC:
Return the source key field names associated with the mapping.
These are in-order with the referenceKeyFieldNames.
Vector fieldNames = new Vector(getSourceKeyFields().size());
for (Enumeration fieldsEnum = getSourceKeyFields().elements();
fieldsEnum.hasMoreElements();) {
fieldNames.addElement(((DatabaseField)fieldsEnum.nextElement()).getQualifiedName());
}
return fieldNames;
|
public java.util.Vector | getSourceKeyFields()INTERNAL:
Return the source key fields.
return sourceKeyFields;
|
public oracle.toplink.essentials.mappings.converters.Converter | getValueConverter()PUBLIC:
Return the converter on the mapping.
A converter can be used to convert between the direct collection's object value and database value.
return valueConverter;
|
protected boolean | hasCustomDeleteQuery()
return hasCustomDeleteQuery;
|
protected boolean | hasCustomInsertQuery()
return hasCustomInsertQuery;
|
public void | initialize(oracle.toplink.essentials.internal.sessions.AbstractSession session)INTERNAL:
Initialize and validate the mapping properties.
if (isKeyForSourceSpecified()) {
initializeSourceKeys(session);
} else {
initializeSourceKeysWithDefaults(session);
}
initializeReferenceTable(session);
initializeReferenceKeys(session);
initializeDirectField(session);
if (shouldInitializeSelectionCriteria()) {
initializeSelectionCriteria(session);
initializeSelectionStatement(session);
}
if (!getSelectionQuery().hasSessionName()) {
getSelectionQuery().setSessionName(session.getName());
}
if ((getValueConverter() != null) && (getSelectionQuery() instanceof DirectReadQuery)) {
((DirectReadQuery)getSelectionQuery()).setValueConverter(getValueConverter());
}
initializeDeleteAllQuery(session);
initializeDeleteQuery(session);
initializeInsertQuery(session);
if (getValueConverter() != null) {
getValueConverter().initialize(this, session);
}
super.initialize(session);
|
protected void | initializeDeleteAllQuery(oracle.toplink.essentials.internal.sessions.AbstractSession session)Initialize delete all query. This query is used to delete the collection of objects from the
reference table.
if (!getDeleteAllQuery().hasSessionName()) {
getDeleteAllQuery().setSessionName(session.getName());
}
if (hasCustomDeleteAllQuery()) {
return;
}
Expression expression = null;
Expression subExp1;
Expression subExp2;
Expression subExpression;
Expression builder = new ExpressionBuilder();
SQLDeleteStatement statement = new SQLDeleteStatement();
// Construct an expression to delete from the relation table.
for (int index = 0; index < getReferenceKeyFields().size(); index++) {
DatabaseField referenceKey = (DatabaseField)getReferenceKeyFields().elementAt(index);
DatabaseField sourceKey = (DatabaseField)getSourceKeyFields().elementAt(index);
subExp1 = builder.getField(referenceKey);
subExp2 = builder.getParameter(sourceKey);
subExpression = subExp1.equal(subExp2);
if (expression == null) {
expression = subExpression;
} else {
expression = expression.and(subExpression);
}
}
statement.setWhereClause(expression);
statement.setTable(getReferenceTable());
getDeleteAllQuery().setSQLStatement(statement);
|
protected void | initializeDeleteQuery(oracle.toplink.essentials.internal.sessions.AbstractSession session)
if (!getDeleteQuery().hasSessionName()) {
getDeleteQuery().setSessionName(session.getName());
}
if (hasCustomDeleteQuery()) {
return;
}
Expression builder = new ExpressionBuilder();
Expression directExp = builder.getField(getDirectField()).equal(builder.getParameter(getDirectField()));
Expression expression = null;
SQLDeleteStatement statement = new SQLDeleteStatement();
// Construct an expression to delete from the relation table.
for (int index = 0; index < getReferenceKeyFields().size(); index++) {
DatabaseField referenceKey = (DatabaseField)getReferenceKeyFields().elementAt(index);
DatabaseField sourceKey = (DatabaseField)getSourceKeyFields().elementAt(index);
Expression subExp1 = builder.getField(referenceKey);
Expression subExp2 = builder.getParameter(sourceKey);
Expression subExpression = subExp1.equal(subExp2);
expression = subExpression.and(expression);
}
expression = expression.and(directExp);
statement.setWhereClause(expression);
statement.setTable(getReferenceTable());
getDeleteQuery().setSQLStatement(statement);
|
protected void | initializeDirectField(oracle.toplink.essentials.internal.sessions.AbstractSession session)The field name on the reference table is initialized and cached.
if (getDirectField() == null) {
throw DescriptorException.directFieldNameNotSet(this);
}
getDirectField().setTable(getReferenceTable());
getDirectField().setIndex(0);
|
protected void | initializeInsertQuery(oracle.toplink.essentials.internal.sessions.AbstractSession session)Initialize insert query. This query is used to insert the collection of objects into the
reference table.
if (!getInsertQuery().hasSessionName()) {
getInsertQuery().setSessionName(session.getName());
}
if (hasCustomInsertQuery()) {
return;
}
SQLInsertStatement statement = new SQLInsertStatement();
statement.setTable(getReferenceTable());
AbstractRecord directRow = new DatabaseRecord();
for (Enumeration referenceEnum = getReferenceKeyFields().elements();
referenceEnum.hasMoreElements();) {
directRow.put((DatabaseField)referenceEnum.nextElement(), null);
}
directRow.put(getDirectField(), null);
statement.setModifyRow(directRow);
getInsertQuery().setSQLStatement(statement);
getInsertQuery().setModifyRow(directRow);
|
protected void | initializeReferenceDescriptor(oracle.toplink.essentials.internal.sessions.AbstractSession session)There is no reference descriptor
;
|
protected void | initializeReferenceKeys(oracle.toplink.essentials.internal.sessions.AbstractSession session)The reference keys on the reference table are initalized
if (getReferenceKeyFields().size() == 0) {
throw DescriptorException.noReferenceKeyIsSpecified(this);
}
for (Enumeration referenceEnum = getReferenceKeyFields().elements();
referenceEnum.hasMoreElements();) {
DatabaseField field = (DatabaseField)referenceEnum.nextElement();
if (field.hasTableName() && (!(field.getTableName().equals(getReferenceTable().getName())))) {
throw DescriptorException.referenceKeyFieldNotProperlySpecified(field, this);
}
field.setTable(getReferenceTable());
}
|
protected void | initializeReferenceTable(oracle.toplink.essentials.internal.sessions.AbstractSession session)
Platform platform = session.getDatasourcePlatform();
if (getReferenceTable() == null) {
throw DescriptorException.referenceTableNotSpecified(this);
}
if (platform.getTableQualifier().length() == 0) {
return;
}
if (getReferenceTable().getTableQualifier().length() == 0) {
getReferenceTable().setTableQualifier(platform.getTableQualifier());
}
|
protected void | initializeSelectionCriteria(oracle.toplink.essentials.internal.sessions.AbstractSession session)
Expression exp1;
Expression exp2;
Expression expression;
Expression criteria = null;
Enumeration referenceKeysEnum;
Enumeration sourceKeysEnum;
ExpressionBuilder base = new ExpressionBuilder();
TableExpression table = (TableExpression)base.getTable(getReferenceTable());
referenceKeysEnum = getReferenceKeyFields().elements();
sourceKeysEnum = getSourceKeyFields().elements();
for (; referenceKeysEnum.hasMoreElements();) {
DatabaseField referenceKey = (DatabaseField)referenceKeysEnum.nextElement();
DatabaseField sourceKey = (DatabaseField)sourceKeysEnum.nextElement();
exp1 = table.getField(referenceKey);
exp2 = base.getParameter(sourceKey);
expression = exp1.equal(exp2);
if (criteria == null) {
criteria = expression;
} else {
criteria = expression.and(criteria);
}
}
setSelectionCriteria(criteria);
|
protected void | initializeSelectionQuery(oracle.toplink.essentials.internal.sessions.AbstractSession session)The selection query is initialized
// Nothing required.
|
protected void | initializeSelectionStatement(oracle.toplink.essentials.internal.sessions.AbstractSession session)
SQLSelectStatement statement = new SQLSelectStatement();
statement.addTable(getReferenceTable());
statement.addField((DatabaseField)getDirectField().clone());
statement.setWhereClause(getSelectionCriteria());
statement.normalize(session, null);
getSelectionQuery().setSQLStatement(statement);
|
protected void | initializeSourceKeys(oracle.toplink.essentials.internal.sessions.AbstractSession session)The source keys are initalized
for (Enumeration sourceKeyEnum = getSourceKeyFields().elements();
sourceKeyEnum.hasMoreElements();) {
getDescriptor().buildField((DatabaseField)sourceKeyEnum.nextElement());
}
|
protected void | initializeSourceKeysWithDefaults(oracle.toplink.essentials.internal.sessions.AbstractSession session)INTERNAL:
If a user does not specify the source key then the primary keys of the source table are used.
List<DatabaseField> primaryKeyFields = getDescriptor().getPrimaryKeyFields();
for (int index = 0; index < primaryKeyFields.size(); index++) {
getSourceKeyFields().addElement(primaryKeyFields.get(index));
}
|
public boolean | isCascadedLockingSupported()INTERNAL
Return true if this mapping supports cascaded version optimistic locking.
return true;
|
public boolean | isChangeTrackingSupported()INTERNAL:
Return if this mapping supports change tracking.
return true;
|
public boolean | isDirectCollectionMapping()INTERNAL:
return true;
|
protected boolean | isKeyForSourceSpecified()INTERNAL:
Checks if source and target keys are mentioned by the user or not.
return !getSourceKeyFields().isEmpty();
|
public boolean | isPrivateOwned()INTERNAL:
Return true if referenced objects are provately owned else false.
return true;
|
public boolean | isRelationalMapping()
return true;
|
public void | iterateOnElement(oracle.toplink.essentials.internal.descriptors.DescriptorIterator iterator, java.lang.Object element)INTERNAL:
Iterate on the specified element.
iterator.iteratePrimitiveForMapping(element, this);
|
public void | iterateOnRealAttributeValue(oracle.toplink.essentials.internal.descriptors.DescriptorIterator iterator, java.lang.Object realAttributeValue)INTERNAL:
Iterate on the attribute value.
The value holder has already been processed.
PERF: Avoid iteration if not required.
if (iterator.shouldIterateOnPrimitives()) {
super.iterateOnRealAttributeValue(iterator, realAttributeValue);
}
|
public void | mergeChangesIntoObject(java.lang.Object target, oracle.toplink.essentials.internal.sessions.ChangeRecord changeRecord, java.lang.Object source, oracle.toplink.essentials.internal.sessions.MergeManager mergeManager)INTERNAL:
Merge changes from the source to the target object.
Because this is a collection mapping, values are added to or removed from the
collection based on the changeset
ContainerPolicy containerPolicy = getContainerPolicy();
Object valueOfTarget = null;
AbstractSession session = mergeManager.getSession();
//collect the changes into a vector
HashMap addObjects = ((DirectCollectionChangeRecord)changeRecord).getAddObjectMap();
HashMap removeObjects = ((DirectCollectionChangeRecord)changeRecord).getRemoveObjectMap();
//Check to see if the target has an instantiated collection
if ((isAttributeValueInstantiated(target)) && (!changeRecord.getOwner().isNew())) {
valueOfTarget = getRealCollectionAttributeValueFromObject(target, session);
} else {
//if not create an instance of the collection
valueOfTarget = containerPolicy.containerInstance(addObjects.size());
}
if (!isAttributeValueInstantiated(target)) {
if (mergeManager.shouldMergeChangesIntoDistributedCache()) {
return;
}
for (Object iterator = containerPolicy.iteratorFor(getRealCollectionAttributeValueFromObject(source, session));
containerPolicy.hasNext(iterator);) {
containerPolicy.addInto(containerPolicy.next(iterator, session), valueOfTarget, session);
}
} else {
synchronized (valueOfTarget) {
// Next iterate over the changes and add them to the container
for (Iterator iterator = addObjects.keySet().iterator(); iterator.hasNext(); ){
Object object = iterator.next();
int objectCount = ((Integer)addObjects.get(object)).intValue();
for (int i = 0; i < objectCount; ++i) {
if (mergeManager.shouldMergeChangesIntoDistributedCache()) {
//bug#4458089 and 4454532- check if collection contains new item before adding during merge into distributed cache
if (!containerPolicy.contains(object, valueOfTarget, session)) {
containerPolicy.addInto(object, valueOfTarget, session);
}
} else {
containerPolicy.addInto(object, valueOfTarget, session);
}
}
}
for (Iterator iterator = removeObjects.keySet().iterator(); iterator.hasNext(); ){
Object object = iterator.next();
int objectCount = ((Integer)removeObjects.get(object)).intValue();
for (int i = 0; i < objectCount; ++i) {
containerPolicy.removeFrom(object, valueOfTarget, session);
}
}
}
}
setRealAttributeValueInObject(target, valueOfTarget);
|
public void | mergeIntoObject(java.lang.Object target, boolean isTargetUnInitialized, java.lang.Object source, oracle.toplink.essentials.internal.sessions.MergeManager mergeManager)INTERNAL:
Merge changes from the source to the target object.
if (isTargetUnInitialized) {
// This will happen if the target object was removed from the cache before the commit was attempted
if (mergeManager.shouldMergeWorkingCopyIntoOriginal() && (!isAttributeValueInstantiated(source))) {
setAttributeValueInObject(target, getIndirectionPolicy().getOriginalIndirectionObject(getAttributeValueFromObject(source), mergeManager.getSession()));
return;
}
}
if (!shouldMergeCascadeReference(mergeManager)) {
// This is only going to happen on mergeClone, and we should not attempt to merge the reference
return;
}
if (mergeManager.shouldMergeOriginalIntoWorkingCopy()) {
if (!isAttributeValueInstantiated(target)) {
// This will occur when the clone's value has not been instantiated yet and we do not need
// the refresh that attribute
return;
}
} else if (!isAttributeValueInstantiated(source)) {
// I am merging from a clone into an original. No need to do merge if the attribute was never
// modified
return;
}
ContainerPolicy containerPolicy = getContainerPolicy();
Object valueOfSource = getRealCollectionAttributeValueFromObject(source, mergeManager.getSession());
// trigger instantiation of target attribute
Object valueOfTarget = getRealCollectionAttributeValueFromObject(target, mergeManager.getSession());
Object newContainer = containerPolicy.containerInstance(containerPolicy.sizeFor(valueOfSource));
boolean fireChangeEvents = false;
valueOfTarget = newContainer;
for (Object sourceValuesIterator = containerPolicy.iteratorFor(valueOfSource);
containerPolicy.hasNext(sourceValuesIterator);) {
Object sourceValue = containerPolicy.next(sourceValuesIterator, mergeManager.getSession());
containerPolicy.addInto(sourceValue, valueOfTarget, mergeManager.getSession());
}
// Must re-set variable to allow for set method to re-morph changes if the collection is not being stored directly.
setRealAttributeValueInObject(target, valueOfTarget);
|
public void | performDataModificationEvent(java.lang.Object[] event, oracle.toplink.essentials.internal.sessions.AbstractSession session)INTERNAL:
Perform the commit event.
This is used in the uow to delay data modifications.
// Hey I might actually want to use an inner class here... ok array for now.
if (event[0] == Delete){
session.executeQuery((DataModifyQuery)event[1], (AbstractRecord)event[(2)]);
} else if (event[0] == Insert) {
session.executeQuery((DataModifyQuery)event[1], (AbstractRecord)event[(2)]);
} else if (event[0] == DeleteAll) {
preDelete((DeleteObjectQuery)event[1]);
} else {
throw DescriptorException.invalidDataModificationEventCode(event[0], this);
}
|
public void | postInsert(oracle.toplink.essentials.queryframework.WriteObjectQuery query)INTERNAL:
Insert the private owned object.
Object objects;
AbstractRecord databaseRow = new DatabaseRecord();
if (isReadOnly()) {
return;
}
objects = getRealCollectionAttributeValueFromObject(query.getObject(), query.getSession());
ContainerPolicy containerPolicy = getContainerPolicy();
if (containerPolicy.isEmpty(objects)) {
return;
}
prepareTranslationRow(query.getTranslationRow(), query.getObject(), query.getSession());
// Extract primary key and value from the source.
for (int index = 0; index < getReferenceKeyFields().size(); index++) {
DatabaseField referenceKey = (DatabaseField)getReferenceKeyFields().elementAt(index);
DatabaseField sourceKey = (DatabaseField)getSourceKeyFields().elementAt(index);
Object sourceKeyValue = query.getTranslationRow().get(sourceKey);
databaseRow.put(referenceKey, sourceKeyValue);
}
// Extract target field and its value. Construct insert statement and execute it
for (Object iter = containerPolicy.iteratorFor(objects); containerPolicy.hasNext(iter);) {
Object object = containerPolicy.next(iter, query.getSession());
if (getValueConverter() != null) {
object = getValueConverter().convertObjectValueToDataValue(object, query.getSession());
}
databaseRow.put(getDirectField(), object);
// In the uow data queries are cached until the end of the commit.
if (query.shouldCascadeOnlyDependentParts()) {
// Hey I might actually want to use an inner class here... ok array for now.
Object[] event = new Object[3];
event[0] = Insert;
event[1] = getInsertQuery();
event[2] = databaseRow.clone();
query.getSession().getCommitManager().addDataModificationEvent(this, event);
} else {
query.getSession().executeQuery(getInsertQuery(), databaseRow);
}
}
|
public void | postUpdate(oracle.toplink.essentials.queryframework.WriteObjectQuery writeQuery)INTERNAL:
Update private owned part.
if (isReadOnly()) {
return;
}
if (writeQuery.getObjectChangeSet() != null){
postUpdateWithChangeSet(writeQuery);
return;
}
// If objects are not instantiated that means they are not changed.
if (!isAttributeValueInstantiated(writeQuery.getObject())) {
return;
}
if (writeQuery.getSession().isUnitOfWork()) {
if (compareObjects(writeQuery.getObject(), writeQuery.getBackupClone(), writeQuery.getSession())) {
return;// Nothing has changed, no work required
}
}
DeleteObjectQuery deleteQuery = new DeleteObjectQuery();
deleteQuery.setObject(writeQuery.getObject());
deleteQuery.setSession(writeQuery.getSession());
deleteQuery.setTranslationRow(writeQuery.getTranslationRow());
if (writeQuery.shouldCascadeOnlyDependentParts()) {
// Hey I might actually want to use an inner class here... ok array for now.
Object[] event = new Object[3];
event[0] = DeleteAll;
event[1] = deleteQuery;
writeQuery.getSession().getCommitManager().addDataModificationEvent(this, event);
} else {
preDelete(deleteQuery);
}
postInsert(writeQuery);
|
protected void | postUpdateWithChangeSet(oracle.toplink.essentials.queryframework.WriteObjectQuery writeQuery)INTERNAL:
Update private owned part.
ObjectChangeSet changeSet = writeQuery.getObjectChangeSet();
DirectCollectionChangeRecord changeRecord = (DirectCollectionChangeRecord)changeSet.getChangesForAttributeNamed(this.getAttributeName());
if (changeRecord == null){
return;
}
for (int index = 0; index < getReferenceKeyFields().size(); index++) {
DatabaseField referenceKey = (DatabaseField)getReferenceKeyFields().elementAt(index);
DatabaseField sourceKey = (DatabaseField)getSourceKeyFields().elementAt(index);
Object sourceKeyValue = writeQuery.getTranslationRow().get(sourceKey);
writeQuery.getTranslationRow().put(referenceKey, sourceKeyValue);
}
for (Iterator iterator = changeRecord.getRemoveObjectMap().keySet().iterator(); iterator.hasNext();){
Object object = iterator.next();
AbstractRecord thisRow = (AbstractRecord)writeQuery.getTranslationRow().clone();
Object value = object;
if (getValueConverter() != null){
value = getValueConverter().convertObjectValueToDataValue(value, writeQuery.getSession());
}
if (value == DirectCollectionChangeRecord.Null){
thisRow.add(getDirectField(), null);
}else{
thisRow.add(getDirectField(), value);
}
// Hey I might actually want to use an inner class here... ok array for now.
Object[] event = new Object[3];
event[0] = Delete;
event[1] = getDeleteQuery();
event[2] = thisRow;
writeQuery.getSession().getCommitManager().addDataModificationEvent(this, event);
Integer count = (Integer)changeRecord.getCommitAddMap().get(object);
if (count != null){
for (int counter = count.intValue(); counter > 0; --counter){
thisRow = (AbstractRecord)writeQuery.getTranslationRow().clone();
thisRow.add(getDirectField(), value);
// Hey I might actually want to use an inner class here... ok array for now.
event = new Object[3];
event[0] = Insert;
event[1] = getInsertQuery();
event[2] = thisRow;
writeQuery.getSession().getCommitManager().addDataModificationEvent(this, event);
}
}
}
for (Iterator iterator = changeRecord.getAddObjectMap().keySet().iterator(); iterator.hasNext();){
Object object = iterator.next();
Integer count = (Integer)changeRecord.getAddObjectMap().get(object);
for (int counter = count.intValue(); counter > 0; --counter){
AbstractRecord thisRow = (AbstractRecord)writeQuery.getTranslationRow().clone();
Object value = object;
if (getValueConverter() != null){
value = getValueConverter().convertObjectValueToDataValue(value, writeQuery.getSession());
}
if (value == DirectCollectionChangeRecord.Null){ //special placeholder for nulls
thisRow.add(getDirectField(), null);
}else{
thisRow.add(getDirectField(), value);
}
// Hey I might actually want to use an inner class here... ok array for now.
Object[] event = new Object[3];
event[0] = Insert;
event[1] = getInsertQuery();
event[2] = thisRow;
writeQuery.getSession().getCommitManager().addDataModificationEvent(this, event);
}
}
|
public void | preDelete(oracle.toplink.essentials.queryframework.WriteObjectQuery query)INTERNAL:
Delete private owned part. Which is a collection of objects from the reference table.
if (isReadOnly()) {
return;
}
prepareTranslationRow(query.getTranslationRow(), query.getObject(), query.getSession());
query.getSession().executeQuery(getDeleteAllQuery(), query.getTranslationRow());
|
protected void | prepareTranslationRow(oracle.toplink.essentials.internal.sessions.AbstractRecord translationRow, java.lang.Object object, oracle.toplink.essentials.internal.sessions.AbstractSession session)INTERNAL:
The translation row may require additional fields than the primary key if the mapping in not on the primary key.
// Make sure that each source key field is in the translation row.
for (Enumeration sourceFieldsEnum = getSourceKeyFields().elements();
sourceFieldsEnum.hasMoreElements();) {
DatabaseField sourceKey = (DatabaseField)sourceFieldsEnum.nextElement();
if (!translationRow.containsKey(sourceKey)) {
Object value = getDescriptor().getObjectBuilder().extractValueFromObjectForField(object, sourceKey, session);
translationRow.put(sourceKey, value);
}
}
|
public void | removeFromCollectionChangeRecord(java.lang.Object newKey, java.lang.Object newValue, oracle.toplink.essentials.internal.sessions.ObjectChangeSet objectChangeSet, oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl uow)INTERNAL:
Remove a value and its change set from the collection change record. This is used by
attribute change tracking.
if (newValue == null) {
newValue = DirectCollectionChangeRecord.Null;
}
ClassDescriptor descriptor;
DirectCollectionChangeRecord collectionChangeRecord = (DirectCollectionChangeRecord)objectChangeSet.getChangesForAttributeNamed(this.getAttributeName());
if (collectionChangeRecord == null) {
collectionChangeRecord = new DirectCollectionChangeRecord(objectChangeSet);
collectionChangeRecord.setAttribute(getAttributeName());
collectionChangeRecord.setMapping(this);
objectChangeSet.addChange(collectionChangeRecord);
Object collection = getRealAttributeValueFromObject(objectChangeSet.getUnitOfWorkClone(), uow);
collectionChangeRecord.storeDatabaseCounts(collection, getContainerPolicy(), uow);
}
collectionChangeRecord.addRemoveChange(newValue, new Integer(1));
|
public void | setContainerPolicy(oracle.toplink.essentials.internal.queryframework.ContainerPolicy containerPolicy)ADVANCED:
Configure the mapping to use a container policy.
The policy manages the access to the collection.
this.containerPolicy = containerPolicy;
((DataReadQuery)getSelectionQuery()).setContainerPolicy(containerPolicy);
|
public void | setCustomDeleteQuery(oracle.toplink.essentials.queryframework.ModifyQuery query)PUBLIC:
The default delete query for this mapping can be overridden by specifying the new query.
This query is responsible for doing the deletion required by the mapping,
such as deletion from join table for M-M. The query should delete a specific row from the
DirectCollectionTable bases on the DirectField.
setDeleteQuery(query);
setHasCustomDeleteQuery(true);
|
public void | setCustomInsertQuery(oracle.toplink.essentials.queryframework.DataModifyQuery query)PUBLIC:
The default insert query for mapping can be overridden by specifying the new query.
This query inserts the row into the direct table.
setInsertQuery(query);
setHasCustomInsertQuery(true);
|
protected void | setDeleteQuery(oracle.toplink.essentials.queryframework.ModifyQuery query)
this.changeSetDeleteQuery = query;
|
public void | setDeleteSQLString(java.lang.String sqlString)PUBLIC:
Set the receiver's delete SQL string. This allows the user to override the SQL
generated by TopLink, with there own SQL or procedure call. The arguments are
translated from the fields of the source row, through replacing the field names
marked by '#' with the values for those fields.
This SQL is responsible for doing the deletion required by the mapping,
such as deletion from join table for M-M.
Example, 'delete from RESPONS where EMP_ID = #EMP_ID and DESCRIP = #DESCRIP'.
DataModifyQuery query = new DataModifyQuery();
query.setSQLString(sqlString);
setCustomDeleteQuery(query);
|
public void | setDirectField(oracle.toplink.essentials.internal.helper.DatabaseField field)PUBLIC:
Set the direct field in the reference table.
This is the field that the primitive data value is stored in.
directField = field;
|
public void | setDirectFieldClassification(java.lang.Class fieldType)ADVANCED:
Set the class type of the field value.
This can be used if field value differs from the object value,
has specific typing requirements such as usage of java.sql.Blob or NChar.
This must be called after the field name has been set.
getDirectField().setType(fieldType);
|
public void | setDirectFieldName(java.lang.String fieldName)PUBLIC:
Set the direct field name in the reference table.
This is the field that the primitive data value is stored in.
setDirectField(new DatabaseField(fieldName));
|
protected void | setHasCustomDeleteQuery(boolean bool)
hasCustomDeleteQuery = bool;
|
protected void | setHasCustomInsertQuery(boolean bool)
hasCustomInsertQuery = bool;
|
protected void | setInsertQuery(oracle.toplink.essentials.queryframework.DataModifyQuery insertQuery)
this.insertQuery = insertQuery;
|
public void | setInsertSQLString(java.lang.String sqlString)PUBLIC:
Set the receiver's insert SQL string. This allows the user to override the SQL
generated by TopLink, with there own SQL or procedure call. The arguments are
translated from the fields of the source row, through replacing the field names
marked by '#' with the values for those fields.
This is used to insert an entry into the direct table.
Example, 'insert into RESPONS (EMP_ID, RES_DESC) values (#EMP_ID, #RES_DESC)'.
DataModifyQuery query = new DataModifyQuery();
query.setSQLString(sqlString);
setCustomInsertQuery(query);
|
public void | setReferenceClass(java.lang.Class referenceClass)INTERNAL:
This cannot be used with direct collection mappings.
return;
|
public void | setReferenceClassName(java.lang.String referenceClassName)
return;
|
public void | setReferenceKeyFieldName(java.lang.String fieldName)PUBLIC:
Set the name of the reference key field.
This is the foreign key field in the direct table referencing the primary key of the source object.
This method is used if the reference key consists of only a single field.
getReferenceKeyFields().addElement(new DatabaseField(fieldName));
|
public void | setReferenceKeyFieldNames(java.util.Vector fieldNames)INTERNAL:
Set the reference key field names associated with the mapping.
These must be in-order with the sourceKeyFieldNames.
Vector fields = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(fieldNames.size());
for (Enumeration fieldNamesEnum = fieldNames.elements(); fieldNamesEnum.hasMoreElements();) {
fields.addElement(new DatabaseField((String)fieldNamesEnum.nextElement()));
}
setReferenceKeyFields(fields);
|
public void | setReferenceKeyFields(java.util.Vector aVector)INTERNAL:
Set the reference fields.
this.referenceKeyFields = aVector;
|
public void | setReferenceTable(oracle.toplink.essentials.internal.helper.DatabaseTable table)INTERNAL:
Set the reference table.
referenceTable = table;
|
public void | setReferenceTableName(java.lang.String tableName)PUBLIC:
Set the reference table name.
if (tableName == null) {
setReferenceTable(null);
} else {
setReferenceTable(new DatabaseTable(tableName));
}
|
public void | setSessionName(java.lang.String name)PUBLIC:
Set the name of the session to execute the mapping's queries under.
This can be used by the session broker to override the default session
to be used for the target class.
super.setSessionName(name);
getInsertQuery().setSessionName(name);
|
public void | setSourceKeyFieldNames(java.util.Vector fieldNames)INTERNAL:
Set the source key field names associated with the mapping.
These must be in-order with the referenceKeyFieldNames.
Vector fields = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(fieldNames.size());
for (Enumeration fieldNamesEnum = fieldNames.elements(); fieldNamesEnum.hasMoreElements();) {
fields.addElement(new DatabaseField((String)fieldNamesEnum.nextElement()));
}
setSourceKeyFields(fields);
|
public void | setSourceKeyFields(java.util.Vector sourceKeyFields)INTERNAL:
Set the source fields.
this.sourceKeyFields = sourceKeyFields;
|
public void | setValueConverter(oracle.toplink.essentials.mappings.converters.Converter valueConverter)PUBLIC:
Set the converter on the mapping.
A converter can be used to convert between the direct collection's object value and database value.
this.valueConverter = valueConverter;
|
public void | simpleAddToCollectionChangeRecord(java.lang.Object referenceKey, java.lang.Object objectToAdd, oracle.toplink.essentials.internal.sessions.ObjectChangeSet changeSet, oracle.toplink.essentials.internal.sessions.AbstractSession session)ADVANCED:
This method is used to have an object add to a collection once the changeSet is applied
The referenceKey parameter should only be used for direct Maps.
DirectCollectionChangeRecord collectionChangeRecord = (DirectCollectionChangeRecord)changeSet.getChangesForAttributeNamed(getAttributeName());
if (collectionChangeRecord == null) {
collectionChangeRecord = new DirectCollectionChangeRecord(changeSet);
collectionChangeRecord.setAttribute(getAttributeName());
collectionChangeRecord.setMapping(this);
changeSet.addChange(collectionChangeRecord);
Object collection = getRealAttributeValueFromObject(changeSet.getUnitOfWorkClone(), session);
collectionChangeRecord.storeDatabaseCounts(collection, getContainerPolicy(), session);
}
collectionChangeRecord.addAdditionChange(objectToAdd, new Integer(1));
|
public void | simpleRemoveFromCollectionChangeRecord(java.lang.Object referenceKey, java.lang.Object objectToRemove, oracle.toplink.essentials.internal.sessions.ObjectChangeSet changeSet, oracle.toplink.essentials.internal.sessions.AbstractSession session)ADVANCED:
This method is used to have an object removed from a collection once the changeSet is applied
The referenceKey parameter should only be used for direct Maps.
DirectCollectionChangeRecord collectionChangeRecord = (DirectCollectionChangeRecord)changeSet.getChangesForAttributeNamed(getAttributeName());
if (collectionChangeRecord == null) {
collectionChangeRecord = new DirectCollectionChangeRecord(changeSet);
collectionChangeRecord.setAttribute(getAttributeName());
collectionChangeRecord.setMapping(this);
changeSet.addChange(collectionChangeRecord);
Object collection = getRealAttributeValueFromObject(changeSet.getUnitOfWorkClone(), session);
collectionChangeRecord.storeDatabaseCounts(collection, getContainerPolicy(), session);
}
collectionChangeRecord.addRemoveChange(objectToRemove, new Integer(1));
|
public void | updateChangeRecord(java.lang.Object clone, java.lang.Object newValue, java.lang.Object oldValue, oracle.toplink.essentials.internal.sessions.ObjectChangeSet objectChangeSet, oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl uow)INTERNAL:
Either create a new change record or update with the new value. This is used
by attribute change tracking.
Specifically in a collection mapping this will be called when the customer
Set a new collection. In this case we will need to mark the change record
with the new and the old versions of the collection.
And mark the ObjectChangeSet with the attribute name then when the changes are calculated
force a compare on the collections to determine changes.
DirectCollectionChangeRecord collectionChangeRecord = (DirectCollectionChangeRecord)objectChangeSet.getChangesForAttributeNamed(this.getAttributeName());
if (collectionChangeRecord == null) {
collectionChangeRecord = new DirectCollectionChangeRecord(objectChangeSet);
collectionChangeRecord.setAttribute(getAttributeName());
collectionChangeRecord.setMapping(this);
objectChangeSet.addChange(collectionChangeRecord);
}
if (collectionChangeRecord.getOriginalCollection() == null){
collectionChangeRecord.setOriginalCollection(oldValue);
}
collectionChangeRecord.setLatestCollection(newValue);
objectChangeSet.deferredDetectionRequiredOn(getAttributeName());
|
public void | useCollectionClass(java.lang.Class concreteClass)PUBLIC:
Configure the mapping to use an instance of the specified container class
to hold the target objects.
jdk1.2.x: The container class must implement (directly or indirectly) the Collection interface.
jdk1.1.x: The container class must be a subclass of Vector.
ContainerPolicy policy = ContainerPolicy.buildPolicyFor(concreteClass);
setContainerPolicy(policy);
|
public void | useMapClass(java.lang.Class concreteClass, java.lang.String methodName)PUBLIC:
It is illegal to use a Map as the container of a DirectCollectionMapping. Only
Collection containers are supported for DirectCollectionMappings.
throw ValidationException.illegalUseOfMapInDirectCollection(this, concreteClass, methodName);
|
public java.lang.Object | valueFromRow(oracle.toplink.essentials.internal.sessions.AbstractRecord row, oracle.toplink.essentials.internal.queryframework.JoinedAttributeManager joinManager, oracle.toplink.essentials.queryframework.ObjectBuildingQuery query, oracle.toplink.essentials.internal.sessions.AbstractSession session)INTERNAL:
Return the value of the reference attribute or a value holder.
Check whether the mapping's attribute should be optimized through batch and joining.
Overridden to support flasback/historical queries.
ReadQuery targetQuery = getSelectionQuery();
return getIndirectionPolicy().valueFromQuery(targetQuery, row, query.getSession());
|
public boolean | verifyDelete(java.lang.Object object, oracle.toplink.essentials.internal.sessions.AbstractSession session)INTERNAL:
Checks if object is deleted from the database or not.
// Row is built for translation
if (isReadOnly()) {
return true;
}
AbstractRecord row = getDescriptor().getObjectBuilder().buildRowForTranslation(object, session);
Object value = session.executeQuery(getSelectionQuery(), row);
return getContainerPolicy().isEmpty(value);
|