use of org.eclipse.persistence.mappings.CollectionMapping in project eclipselink by eclipse-ee4j.
the class AbstractPersistenceUnitResource method addMapping.
@SuppressWarnings("rawtypes")
private void addMapping(Descriptor descriptor, DatabaseMapping mapping) {
String target = null;
String collectionName = null;
if (mapping.isCollectionMapping()) {
if (mapping.isEISMapping()) {
EISCompositeCollectionMapping collectionMapping = (EISCompositeCollectionMapping) mapping;
Class collectionClass = collectionMapping.getContainerPolicy().getContainerClass();
String collectionType = getSimplePublicCollectionTypeName(collectionClass);
if (collectionType == null) {
collectionType = collectionClass.getSimpleName();
}
if (collectionMapping.getReferenceClass() != null) {
collectionName = collectionMapping.getReferenceClass().getSimpleName();
}
if ((collectionName == null) && (collectionMapping.getAttributeClassification() != null)) {
collectionName = collectionMapping.getAttributeClassification().getSimpleName();
}
if (collectionMapping.getContainerPolicy().isMapPolicy()) {
String mapKeyType = collectionMapping.getContainerPolicy().getKeyType().getClass().getSimpleName();
target = collectionType + "<" + mapKeyType + ", " + collectionName + ">";
} else {
target = collectionType + "<" + collectionName + ">";
}
} else {
CollectionMapping collectionMapping = (CollectionMapping) mapping;
Class collectionClass = collectionMapping.getContainerPolicy().getContainerClass();
String collectionType = getSimplePublicCollectionTypeName(collectionClass);
if (collectionType == null) {
collectionType = collectionClass.getSimpleName();
}
if (collectionMapping.getReferenceClass() != null) {
collectionName = collectionMapping.getReferenceClass().getSimpleName();
}
if ((collectionName == null) && (collectionMapping.getAttributeClassification() != null)) {
collectionName = collectionMapping.getAttributeClassification().getSimpleName();
}
if (collectionMapping.getContainerPolicy().isMapPolicy()) {
String mapKeyType = collectionMapping.getContainerPolicy().getKeyType().getClass().getSimpleName();
target = collectionType + "<" + mapKeyType + ", " + collectionName + ">";
} else {
target = collectionType + "<" + collectionName + ">";
}
}
} else if (mapping.isForeignReferenceMapping()) {
target = ((ForeignReferenceMapping) mapping).getReferenceClass().getSimpleName();
} else {
target = mapping.getAttributeClassification().getSimpleName();
}
descriptor.getAttributes().add(new Attribute(mapping.getAttributeName(), target));
}
use of org.eclipse.persistence.mappings.CollectionMapping in project eclipselink by eclipse-ee4j.
the class DirectCollectionAccessor method process.
/**
* INTERNAL:
*/
protected void process(DatabaseMapping mapping) {
// Add the mapping to the descriptor.
setMapping(mapping);
// Set the attribute name.
mapping.setAttributeName(getAttributeName());
// Will check for PROPERTY access
setAccessorMethods(mapping);
if (mapping instanceof CollectionMapping) {
CollectionMapping collectionMapping = (CollectionMapping) mapping;
// Set the reference class name.
collectionMapping.setReferenceClassName(getReferenceClassName());
// Process join fetch type.
processJoinFetch(getJoinFetch(), collectionMapping);
// Process the batch fetch if specified.
processBatchFetch(collectionMapping);
// Process the collection table.
processCollectionTable(collectionMapping);
// The spec. requires pessimistic lock to be extend-able to CollectionTable
collectionMapping.setShouldExtendPessimisticLockScope(true);
// Set the cascade on delete if specified.
collectionMapping.setIsCascadeOnDeleteSetOnDatabase(isCascadeOnDelete());
} else if (mapping instanceof AggregateMapping) {
AggregateMapping aggregateMapping = (AggregateMapping) mapping;
// Set the reference class name.
aggregateMapping.setReferenceClassName(getReferenceClassName());
}
// Set the non cacheable if specified.
mapping.setIsCacheable(!isNonCacheable());
// Process a @ReturnInsert and @ReturnUpdate (to log a warning message)
processReturnInsertAndUpdate();
// Process any partitioning policies.
processPartitioning();
}
Aggregations