/** * INTERNAL: * The mapping clones itself to create deep copy. */ public Object clone() { ManyToManyMapping clone = (ManyToManyMapping)super.clone(); clone.setTargetKeyFields(cloneFields(getTargetKeyFields())); clone.setSourceKeyFields(cloneFields(getSourceKeyFields())); clone.setTargetRelationKeyFields(cloneFields(getTargetRelationKeyFields())); clone.setSourceRelationKeyFields(cloneFields(getSourceRelationKeyFields())); return clone; }
/** * INTERNAL: * The mapping clones itself to create deep copy. */ public Object clone() { DirectCollectionMapping clone = (DirectCollectionMapping)super.clone(); clone.setSourceKeyFields(cloneFields(getSourceKeyFields())); clone.setReferenceKeyFields(cloneFields(getReferenceKeyFields())); return clone; }
/** * PUBLIC: * Sets the name of the attribute in the mapping. */ public void setAttributeName(String attributeName) { getAttributeAccessor().setAttributeName(attributeName); }
/** * PUBLIC: * Return the name of the attribute set in the mapping. */ public String getAttributeName() { return getAttributeAccessor().getAttributeName(); }
/** * INTERNAL: * Compare the attributes belonging to this mapping for the objects. */ public boolean compareObjects(Object firstObject, Object secondObject, AbstractSession session) { if (isPrivateOwned()) { return compareObjectsWithPrivateOwned(firstObject, secondObject, session); } else { return compareObjectsWithoutPrivateOwned(firstObject, secondObject, 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. */ public Object valueFromRow(AbstractRecord row, JoinedAttributeManager joinManager, ObjectBuildingQuery query, AbstractSession executionSession) throws DatabaseException { if(shouldUseValueFromRowWithJoin(joinManager)) { return valueFromRowInternalWithJoin(row, joinManager, executionSession); } else { return valueFromRowInternal(row, joinManager, executionSession); } }
/** * INTERNAL: * Copy of the attribute of the object. * This is NOT used for unit of work but for templatizing an object. */ public void buildCopy(Object copy, Object original, ObjectCopyingPolicy policy) { Object attributeValue = getAttributeValueFromObject(original); setAttributeValueInObject(copy, buildCopyOfAttributeValue(attributeValue, policy)); }
/** * INTERNAL: * Compare the attributes belonging to this mapping for the objects. */ public boolean compareObjects(Object firstObject, Object secondObject, AbstractSession session) { Object firstObjectCollection = getRealCollectionAttributeValueFromObject(firstObject, session); Object secondObjectCollection = getRealCollectionAttributeValueFromObject(secondObject, session); return super.compareObjects(firstObjectCollection, secondObjectCollection, session); }
/** * PUBLIC: * The default insert query for mapping can be overridden by specifying the new query. * This query inserts the row into the direct table. */ public void setCustomInsertQuery(DataModifyQuery query) { setInsertQuery(query); setHasCustomInsertQuery(true); }
/** * PUBLIC: * The default delete all query for mapping can be overridden by specifying the new query. * This query is responsible for doing the deletion required by the mapping, * such as deletion of all the rows from join table for M-M, or optimized delete all of target objects for 1-M. */ public void setCustomDeleteAllQuery(ModifyQuery query) { setDeleteAllQuery(query); setHasCustomDeleteAllQuery(true); }
/** * INTERNAL: * Build an aggregate object from the specified row and put it * in the specified target object. */ public Object readFromRowIntoObject(AbstractRecord databaseRow, JoinedAttributeManager joinManager, Object targetObject, ObjectBuildingQuery sourceQuery, AbstractSession executionSession) throws DatabaseException { Object aggregate = buildAggregateFromRow(databaseRow, targetObject, joinManager, false, executionSession);// don't just build a shallow original setAttributeValueInObject(targetObject, aggregate); return aggregate; }
/** * PUBLIC: * Relationship mappings creates a read query to read reference objects. If this default * query needs to be customize then user can specify its own read query to do the reading * of reference objects. One must instance of ReadQuery or subclasses of the ReadQuery. */ public void setCustomSelectionQuery(ReadQuery query) { setSelectionQuery(query); setHasCustomSelectionQuery(true); }
protected boolean shouldInitializeSelectionCriteria() { if (hasCustomSelectionQuery()) { return false; } if (getSelectionCriteria() == null) { return true; } return false; }
/** * INTERNAL: * Return the value of an attribute unwrapping value holders if required. */ public Object getRealAttributeValueFromObject(Object object, AbstractSession session) throws DescriptorException { return getAttributeValueFromObject(object); }
/** * INTERNAL: * The join table is a dependency if not read-only. */ public boolean hasDependency() { return isPrivateOwned() || (!isReadOnly()); }
/** * INTERNAL: * An object is still in the collection, update it as it may have changed. */ protected void objectUnchangedDuringUpdate(ObjectLevelModifyQuery query, Object object, Hashtable backupclones, CacheKey keys) throws DatabaseException, OptimisticLockException { objectUnchangedDuringUpdate(query, object); }
/** * INTERNAL: * This row is built for shallow insert which happens in case of bidirectional inserts. */ public void writeFromObjectIntoRowForShallowInsert(Object object, AbstractRecord databaseRow, AbstractSession session) { writeFromObjectIntoRowForShallowOperation(object, databaseRow, session); }
/** * INTERNAL: * This is used to preserve object identity during a refreshObject() * query. Return the object corresponding to the specified database row. * The default is to simply return the attribute value. */ protected Object getMatchingAttributeValueFromObject(AbstractRecord row, Object targetObject, AbstractSession session, ClassDescriptor descriptor) { return getAttributeValueFromObject(targetObject); }
/** * INTERNAL: * Maintain for backward compatibility. * This is 'public' so StoredProcedureGenerator * does not have to use the custom query expressions. */ public Map getTargetForeignKeyToSourceKeys() { return this.getTargetForeignKeysToSourceKeys(); }
/** * INTERNAL: * Returns whether the mapping has any constraint dependencies, such as * join table entries. This dependency is important for deletes from * unidirectional relationships. */ public boolean hasConstraintDependency() { // Set a dependency on the owning side return !isReadOnly(); }