/** * PUBLIC: * Provide order support for queryKeyName in descending or ascending order. * Called from the EJBAnnotationsProcessor when an @OrderBy is found. */ public void addOrderBy(String queryKeyName, boolean isDescending) { this.hasOrderBy = true; if (isDescending) { addDescendingOrdering(queryKeyName); } else { addAscendingOrdering(queryKeyName); } }
/** * INTERNAL: * The mapping clones itself to create deep copy. */ public Object clone() { AggregateCollectionMapping mappingObject = (AggregateCollectionMapping)super.clone(); mappingObject.setTargetForeignKeyToSourceKeys(new HashMap(getTargetForeignKeyToSourceKeys())); return mappingObject; }
/** * INTERNAL: * Initialize the state of mapping. */ public void initialize(AbstractSession session) throws DescriptorException { super.initialize(session); setFields(collectFields()); getContainerPolicy().prepare(getSelectionQuery(), session); // Check that the container policy is correct for the collection type. if ((!usesIndirection()) && (!getAttributeAccessor().getAttributeClass().isAssignableFrom(getContainerPolicy().getContainerClass()))) { throw DescriptorException.incorrectCollectionPolicy(this, getAttributeAccessor().getAttributeClass(), getContainerPolicy().getContainerClass()); } }
mapping.useTransparentMap(mapKey); } else if (rawClass == List.class) { mapping.useTransparentList(); } else if (rawClass == Collection.class) { mapping.useTransparentCollection(); mapping.setContainerPolicy(new CollectionContainerPolicy(ClassConstants.IndirectList_Class)); } else if (rawClass == Set.class) { mapping.useTransparentSet(); } else { mapping.dontUseIndirection(); mapping.useMapClass(java.util.Hashtable.class, mapKey); } else if (rawClass == Set.class) { mapping.useCollectionClass(java.util.HashSet.class); } else { mapping.useCollectionClass(java.util.Vector.class);
cloneAttribute = getAttributeValueFromObject(clone); if ((cloneAttribute != null) && (!getIndirectionPolicy().objectIsInstantiated(cloneAttribute))) { return null; backUpAttribute = getAttributeValueFromObject(backUp); backUpObjectCollection = getRealCollectionAttributeValueFromObject(backUp, session); cloneObjectCollection = getRealCollectionAttributeValueFromObject(clone, session); } else { cloneObjectCollection = getContainerPolicy().containerInstance(1); changeRecord.setAttribute(getAttributeName()); changeRecord.setMapping(this); compareCollectionsForChange(backUpObjectCollection, cloneObjectCollection, changeRecord, session); if (changeRecord.hasChanges()) { return changeRecord;
mapping.addAggregateOrderBy(embeddedIdAttributeName, orderByAttribute, false); mapping.addOrderBy(orderByAttribute, false); mapping.addAggregateOrderBy(attributeName, orderByAttributeName, ordering.equals(MetadataConstants.DESCENDING)); mapping.addOrderBy(attributeName, ordering.equals(MetadataConstants.DESCENDING));
/** * INTERNAL: * Require for cloning, the part must be cloned. * Ignore the objects, use the attribute value. */ public Object buildCloneForPartObject(Object attributeValue, Object original, Object clone, UnitOfWorkImpl unitOfWork, boolean isExisting) { ContainerPolicy containerPolicy = getContainerPolicy(); if (attributeValue == null) { Object container = containerPolicy.containerInstance(1); return container; } Object clonedAttributeValue = containerPolicy.containerInstance(containerPolicy.sizeFor(attributeValue)); // I need to synchronize here to prevent the collection from changing while I am cloning it. // This will occur when I am merging into the cache and I am instantiating a UOW valueHolder at the same time // I can not synchronize around the clone, as this will cause deadlocks, so I will need to copy the collection then create the clones // I will use a temporary collection to help speed up the process Object temporaryCollection = null; synchronized (attributeValue) { temporaryCollection = containerPolicy.cloneFor(attributeValue); } for (Object valuesIterator = containerPolicy.iteratorFor(temporaryCollection); containerPolicy.hasNext(valuesIterator);) { Object cloneValue = buildElementClone(containerPolicy.next(valuesIterator, unitOfWork), unitOfWork, isExisting); containerPolicy.addInto(cloneValue, clonedAttributeValue, unitOfWork); } return clonedAttributeValue; }
/** * 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. */ public void calculateDeferredChanges(ChangeRecord changeRecord, AbstractSession session){ CollectionChangeRecord collectionRecord = (CollectionChangeRecord) changeRecord; //clear incase events were fired since the set of the collection // collectionRecord.getAddObjectList().clear(); // collectionRecord.getRemoveObjectList().clear(); compareCollectionsForChange(collectionRecord.getOriginalCollection(), collectionRecord.getLatestCollection(), collectionRecord, session); }
/** * INTERNAL: * Convert all the class-name-based settings in this mapping to actual class-based * settings * This method is implemented by subclasses as necessary. * @param classLoader */ public void convertClassNamesToClasses(ClassLoader classLoader){ 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); } } };
/** * INTERNAL: * Clone the appropriate attributes. */ public Object clone() { OneToManyMapping clone = (OneToManyMapping)super.clone(); clone.setTargetForeignKeysToSourceKeys(new HashMap(this.getTargetForeignKeysToSourceKeys())); 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; }
/** * 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; }