use of org.eclipse.persistence.mappings.AggregateObjectMapping in project jmix by jmix-framework.
the class EmbeddedAttributesMappingProcessor method process.
@Override
public void process(MappingProcessorContext context) {
DatabaseMapping mapping = context.getMapping();
if (mapping instanceof AggregateObjectMapping) {
MetaClass metaClass = metadata.getClass(mapping.getDescriptor().getJavaClass());
MetaProperty metaProperty = metaClass.getProperty(mapping.getAttributeName());
EmbeddedParameters embeddedParameters = metaProperty.getAnnotatedElement().getAnnotation(EmbeddedParameters.class);
if (embeddedParameters != null && !embeddedParameters.nullAllowed()) {
((AggregateObjectMapping) mapping).setIsNullAllowed(false);
}
}
}
use of org.eclipse.persistence.mappings.AggregateObjectMapping in project eclipselink by eclipse-ee4j.
the class MappingAccessor method processEmbeddableMapKeyClass.
/**
* INTERNAL:
*/
protected AggregateObjectMapping processEmbeddableMapKeyClass(MappedKeyMapAccessor mappedKeyMapAccessor) {
AggregateObjectMapping keyMapping = new AggregateObjectMapping();
MetadataClass mapKeyClass = mappedKeyMapAccessor.getMapKeyClass();
keyMapping.setReferenceClassName(mapKeyClass.getName());
// The embeddable accessor must be processed by now. If it is not then
// we are in trouble since by the time we get here, we are too late in
// the cycle to process embeddable classes and their accessors. See
// MetadataProject processStage3(), processEmbeddableMappingAccessors.
// At this stage all class accessors (embeddable, entity and mapped
// superclass) have to have been processed to gather all their
// relational and embedded mappings.
EmbeddableAccessor mapKeyAccessor = getProject().getEmbeddableAccessor(mapKeyClass);
// Ensure the reference descriptor is marked as an embeddable collection.
mapKeyAccessor.getDescriptor().setIsEmbeddable();
// Process the attribute overrides for this may key embeddable.
processAttributeOverrides(mappedKeyMapAccessor.getMapKeyAttributeOverrides(), keyMapping, mapKeyAccessor.getDescriptor());
// Process the association overrides for this may key embeddable.
processAssociationOverrides(mappedKeyMapAccessor.getMapKeyAssociationOverrides(), keyMapping, mapKeyAccessor.getDescriptor());
// Process a convert key or jpa converter for the map key if specified.
processConverts(getMapKeyConverts(mappedKeyMapAccessor.getMapKeyConverts()), keyMapping, mappedKeyMapAccessor.getMapKeyClass(), true);
keyMapping.setDescriptor(getDescriptor().getClassDescriptor());
return keyMapping;
}
use of org.eclipse.persistence.mappings.AggregateObjectMapping in project eclipselink by eclipse-ee4j.
the class EmbeddedAccessor method process.
/**
* INTERNAL:
* Process an embedded.
*/
@Override
public void process() {
// Build and aggregate object mapping and add it to the descriptor.
AggregateMapping mapping = getOwningDescriptor().getClassDescriptor().newAggregateMapping();
setMapping(mapping);
mapping.setReferenceClassName(getReferenceClassName());
mapping.setAttributeName(getAttributeName());
// Will check for PROPERTY access
setAccessorMethods(mapping);
// EIS and ORDT mappings may not be aggregate object mappings.
if (mapping.isAggregateObjectMapping()) {
AggregateObjectMapping aggregateMapping = (AggregateObjectMapping) mapping;
aggregateMapping.setIsNullAllowed(true);
// Process attribute overrides.
processAttributeOverrides(m_attributeOverrides, aggregateMapping, getReferenceDescriptor());
// Process association overrides.
processAssociationOverrides(m_associationOverrides, aggregateMapping, getReferenceDescriptor());
// Process converts.
processConverts(getConverts(m_converts), aggregateMapping, getReferenceClass(), false);
} else if (mapping.isAbstractCompositeObjectMapping()) {
((AbstractCompositeObjectMapping) mapping).setField(getDatabaseField(getDescriptor().getPrimaryTable(), MetadataLogger.COLUMN));
}
// Process a @ReturnInsert and @ReturnUpdate (to log a warning message)
processReturnInsertAndUpdate();
}
use of org.eclipse.persistence.mappings.AggregateObjectMapping in project eclipselink by eclipse-ee4j.
the class ALCTEmployeeProject method buildEmployeeDescriptor.
public ClassDescriptor buildEmployeeDescriptor() {
RelationalDescriptor descriptor = new RelationalDescriptor();
descriptor.setJavaClass(ALCTEmployee.class);
descriptor.addTableName("ALCTEMPLOYEE");
descriptor.addPrimaryKeyFieldName("ALCTEMPLOYEE.EMP_ID");
// Descriptor Properties.
descriptor.useSoftCacheWeakIdentityMap();
descriptor.setIdentityMapSize(100);
descriptor.useRemoteSoftCacheWeakIdentityMap();
descriptor.setRemoteIdentityMapSize(100);
descriptor.setSequenceNumberFieldName("ALCTEMPLOYEE.EMP_ID");
descriptor.setSequenceNumberName("EMP_SEQ");
VersionLockingPolicy lockingPolicy = new VersionLockingPolicy();
lockingPolicy.setWriteLockFieldName("ALCTEMPLOYEE.VERSION");
descriptor.setOptimisticLockingPolicy(lockingPolicy);
descriptor.setAlias("ALCTEmployee");
// Change Tracking
descriptor.setObjectChangePolicy(new AttributeChangeTrackingPolicy());
// Cache Invalidation Policy
// Query Manager.
descriptor.getQueryManager().checkCacheForDoesExist();
descriptor.getQueryManager().setQueryTimeout(0);
// Named Queries.
// Event Manager.
// Mappings.
DirectToFieldMapping firstNameMapping = new DirectToFieldMapping();
firstNameMapping.setAttributeName("firstName");
firstNameMapping.setFieldName("ALCTEMPLOYEE.F_NAME");
firstNameMapping.setNullValue("");
descriptor.addMapping(firstNameMapping);
DirectToFieldMapping idMapping = new DirectToFieldMapping();
idMapping.setAttributeName("id");
idMapping.setFieldName("ALCTEMPLOYEE.EMP_ID");
descriptor.addMapping(idMapping);
DirectToFieldMapping lastNameMapping = new DirectToFieldMapping();
lastNameMapping.setAttributeName("lastName");
lastNameMapping.setFieldName("ALCTEMPLOYEE.L_NAME");
lastNameMapping.setNullValue("");
descriptor.addMapping(lastNameMapping);
DirectToFieldMapping genderMapping = new DirectToFieldMapping();
genderMapping.setAttributeName("gender");
genderMapping.setFieldName("ALCTEMPLOYEE.GENDER");
ObjectTypeConverter genderMappingConverter = new ObjectTypeConverter();
genderMappingConverter.addConversionValue("F", "Female");
genderMappingConverter.addConversionValue("M", "Male");
genderMapping.setConverter(genderMappingConverter);
descriptor.addMapping(genderMapping);
AggregateObjectMapping periodMapping = new AggregateObjectMapping();
periodMapping.setAttributeName("period");
periodMapping.setReferenceClass(ALCTEmploymentPeriod.class);
periodMapping.setIsNullAllowed(true);
periodMapping.addFieldNameTranslation("ALCTEMPLOYEE.END_DATE", "endDate->DIRECT");
periodMapping.addFieldNameTranslation("ALCTEMPLOYEE.START_DATE", "startDate->DIRECT");
descriptor.addMapping(periodMapping);
return descriptor;
}
use of org.eclipse.persistence.mappings.AggregateObjectMapping in project eclipselink by eclipse-ee4j.
the class MapCollectionsProject method buildAggregateDirectMapHolderDescriptor.
protected void buildAggregateDirectMapHolderDescriptor() {
RelationalDescriptor descriptor = new RelationalDescriptor();
// SECTION: DESCRIPTOR
descriptor.setJavaClass(AggregateDirectMapHolder.class);
Vector vector = new Vector();
vector.addElement("AGG_DIR_MAP_HOLDER");
descriptor.setTableNames(vector);
descriptor.addPrimaryKeyFieldName("AGG_DIR_MAP_HOLDER.ID");
// SECTION: PROPERTIES
descriptor.setIdentityMapClass(org.eclipse.persistence.internal.identitymaps.FullIdentityMap.class);
descriptor.setExistenceChecking("Check cache");
descriptor.setIdentityMapSize(100);
descriptor.setSequenceNumberName("AGG_DIR_MAP_HOLDER_ID");
descriptor.setSequenceNumberFieldName("ID");
// SECTION: DIRECTTOFIELDMAPPING
org.eclipse.persistence.mappings.DirectToFieldMapping directtofieldmapping = new org.eclipse.persistence.mappings.DirectToFieldMapping();
directtofieldmapping.setAttributeName("id");
directtofieldmapping.setIsReadOnly(false);
directtofieldmapping.setGetMethodName("getId");
directtofieldmapping.setSetMethodName("setId");
directtofieldmapping.setFieldName("AGG_DIR_MAP_HOLDER.ID");
descriptor.addMapping(directtofieldmapping);
DirectMapMapping directMapMapping = new DirectMapMapping();
directMapMapping.setAttributeName("aggregateToDirectMap");
directMapMapping.setGetMethodName("getAggregateToDirectMap");
directMapMapping.setSetMethodName("setAggregateToDirectMap");
directMapMapping.setReferenceTableName("AGG_DIR_MAP_REL");
directMapMapping.setDirectFieldName("AGG_DIR_MAP_REL.MAP_VALUE");
directMapMapping.addReferenceKeyFieldName("AGG_DIR_MAP_REL.HOLDER_ID", "AGG_DIR_MAP_HOLDER.ID");
directMapMapping.setDirectFieldClassification(Integer.class);
directMapMapping.setIndirectionPolicy(new TransparentIndirectionPolicy());
AggregateObjectMapping keyMapping = new AggregateObjectMapping();
keyMapping.setReferenceClass(AggregateMapKey.class);
keyMapping.addFieldNameTranslation("AGG_DIR_MAP_REL.MAP_KEY", "key->DIRECT");
keyMapping.setDescriptor(descriptor);
MappedKeyMapContainerPolicy policy = new MappedKeyMapContainerPolicy(IndirectMap.class);
policy.setKeyMapping(keyMapping);
policy.setValueMapping(directMapMapping);
directMapMapping.setContainerPolicy(policy);
descriptor.addMapping(directMapMapping);
addDescriptor(descriptor);
}
Aggregations