use of org.eclipse.persistence.mappings.foundation.MapKeyMapping in project eclipselink by eclipse-ee4j.
the class MapAttributeImpl method getOwningPKTypeWhenMapKeyAnnotationMissingOrDefaulted.
/**
* INTERNAL:
* Default to the PK of the owning descriptor when no MapKey or MapKey:name attribute is specified.
* Prerequisites: policy on the mapping is of type MappedKeyMapPolicy
*/
private Class<?> getOwningPKTypeWhenMapKeyAnnotationMissingOrDefaulted(MappedKeyMapContainerPolicy policy) {
Class<?> javaClass = null;
;
MapKeyMapping mapKeyMapping = policy.getKeyMapping();
ClassDescriptor descriptor = ((DatabaseMapping) mapKeyMapping).getDescriptor();
// If the reference descriptor is null then we are on a direct mapping
if (null != descriptor) {
javaClass = ((DatabaseMapping) mapKeyMapping).getAttributeClassification();
if (null == javaClass) {
// Default to the PK of the owning descriptor when no MapKey or MapKey:name attribute is specified
if (descriptor.getCMPPolicy() != null) {
javaClass = descriptor.getCMPPolicy().getPKClass();
}
}
}
return javaClass;
}
use of org.eclipse.persistence.mappings.foundation.MapKeyMapping in project eclipselink by eclipse-ee4j.
the class MappingAccessor method processMapKeyClass.
/**
* INTERNAL:
* Process a map key class for the given map key map accessor.
*/
protected void processMapKeyClass(ContainerMapping mapping, MappedKeyMapAccessor mappedKeyMapAccessor) {
MapKeyMapping keyMapping;
MetadataClass mapKeyClass = mappedKeyMapAccessor.getMapKeyClass();
if (getProject().hasEntity(mapKeyClass)) {
keyMapping = processEntityMapKeyClass(mappedKeyMapAccessor);
} else if (getProject().hasEmbeddable(mapKeyClass)) {
keyMapping = processEmbeddableMapKeyClass(mappedKeyMapAccessor);
} else {
keyMapping = processDirectMapKeyClass(mappedKeyMapAccessor);
}
Class<?> containerClass;
if (mapping instanceof ForeignReferenceMapping) {
if (usesIndirection()) {
containerClass = ClassConstants.IndirectMap_Class;
((ForeignReferenceMapping) mapping).setIndirectionPolicy(new TransparentIndirectionPolicy());
} else {
containerClass = java.util.Hashtable.class;
((ForeignReferenceMapping) mapping).dontUseIndirection();
}
} else {
containerClass = java.util.Hashtable.class;
}
MappedKeyMapContainerPolicy policy = new MappedKeyMapContainerPolicy(containerClass);
policy.setKeyMapping(keyMapping);
policy.setValueMapping((MapComponentMapping) mapping);
mapping.setContainerPolicy(policy);
}
Aggregations