use of org.eclipse.persistence.mappings.foundation.AbstractCompositeDirectCollectionMapping in project eclipselink by eclipse-ee4j.
the class DirectCollectionAccessor method processDirectCollectionMapping.
/**
* INTERNAL:
*/
protected void processDirectCollectionMapping() {
// Initialize our mapping.
DatabaseMapping mapping = getOwningDescriptor().getClassDescriptor().newDirectCollectionMapping();
// Process common direct collection metadata. This must be done
// before any field processing since field processing requires that
// the collection table be processed before hand.
process(mapping);
processContainerPolicyAndIndirection((ContainerMapping) mapping);
if (mapping instanceof DirectCollectionMapping) {
DirectCollectionMapping directCollectionMapping = (DirectCollectionMapping) mapping;
// Process the container and indirection policies.
// Process the value column (we must process this field before the
// call to processConverter, since it may set a field classification)
directCollectionMapping.setDirectField(getDatabaseField(getReferenceDatabaseTable(), MetadataLogger.VALUE_COLUMN));
// mapping to ensure we do the right conversions.
if (hasAttributeType() || getAccessibleObject().isGenericCollectionType()) {
directCollectionMapping.setDirectFieldClassificationName(getJavaClassName(getReferenceClass()));
}
} else if (mapping.isAbstractCompositeDirectCollectionMapping()) {
((AbstractCompositeDirectCollectionMapping) mapping).setField(getDatabaseField(getDescriptor().getPrimaryTable(), MetadataLogger.COLUMN));
}
// Process a converter for this mapping. We will look for a convert
// value. If none is found then we'll look for a JPA converter, that
// is, Enumerated, Lob and Temporal. With everything falling into
// a serialized mapping if no converter whatsoever is found.
processMappingValueConverter(mapping, getValueConverter(), getConverts(), getReferenceClass(), getReferenceClassWithGenerics());
}
use of org.eclipse.persistence.mappings.foundation.AbstractCompositeDirectCollectionMapping in project eclipselink by eclipse-ee4j.
the class XMLChoiceCollectionMapping method initialize.
@Override
public void initialize(AbstractSession session) throws DescriptorException {
super.initialize(session);
if (this.converter != null) {
this.converter.initialize(this, session);
}
ArrayList<XMLMapping> mappingsList = new ArrayList<>();
mappingsList.addAll(getChoiceElementMappings().values());
for (XMLMapping next : getChoiceElementMappingsByClass().values()) {
if (!(mappingsList.contains(next))) {
mappingsList.add(next);
}
}
if (isAny) {
// anyMapping = new XMLAnyCollectionMapping();
mappingsList.add(anyMapping);
}
Iterator<XMLMapping> mappings = mappingsList.iterator();
while (mappings.hasNext()) {
DatabaseMapping nextMapping = (DatabaseMapping) mappings.next();
Converter converter = null;
if (fieldsToConverters != null) {
converter = fieldsToConverters.get(nextMapping.getField());
}
if (nextMapping.isAbstractCompositeDirectCollectionMapping()) {
XMLConversionManager xmlConversionManager = (XMLConversionManager) session.getDatasourcePlatform().getConversionManager();
QName schemaType = xmlConversionManager.schemaType(((AbstractCompositeDirectCollectionMapping) nextMapping).getAttributeElementClass());
if (schemaType != null) {
((XMLField) nextMapping.getField()).setSchemaType(schemaType);
}
if (converter != null) {
((AbstractCompositeDirectCollectionMapping) nextMapping).setValueConverter(converter);
}
((AbstractCompositeDirectCollectionMapping) nextMapping).setContainerPolicy(getContainerPolicy());
} else if (nextMapping.isAbstractCompositeCollectionMapping()) {
if (converter != null) {
((AbstractCompositeCollectionMapping) nextMapping).setConverter(converter);
}
((AbstractCompositeCollectionMapping) nextMapping).setContainerPolicy(getContainerPolicy());
} else if (nextMapping instanceof XMLBinaryDataCollectionMapping) {
((XMLBinaryDataCollectionMapping) nextMapping).setContainerPolicy(getContainerPolicy());
if (converter != null) {
((XMLBinaryDataCollectionMapping) nextMapping).setValueConverter(converter);
}
} else if (nextMapping instanceof XMLAnyCollectionMapping) {
((XMLAnyCollectionMapping) nextMapping).setContainerPolicy(getContainerPolicy());
if (converter != null && converter instanceof XMLConverter) {
((XMLAnyCollectionMapping) nextMapping).setConverter((XMLConverter) converter);
}
} else {
((XMLCollectionReferenceMapping) nextMapping).setContainerPolicy(getContainerPolicy());
((XMLCollectionReferenceMapping) nextMapping).setReuseContainer(true);
}
nextMapping.initialize(session);
}
}
Aggregations