Search in sources :

Example 21 with AggregateObjectMapping

use of org.eclipse.persistence.mappings.AggregateObjectMapping in project cuba by cuba-platform.

the class EmbeddedAttributesMappingProcessor method process.

@Override
public void process(MappingProcessorContext context) {
    DatabaseMapping mapping = context.getMapping();
    if (mapping instanceof AggregateObjectMapping) {
        ClassDescriptor descriptor = mapping.getDescriptor();
        Field referenceField = FieldUtils.getFieldsListWithAnnotation(descriptor.getJavaClass(), EmbeddedParameters.class).stream().filter(f -> f.getName().equals(mapping.getAttributeName())).findFirst().orElse(null);
        if (referenceField != null) {
            EmbeddedParameters embeddedParameters = referenceField.getAnnotation(EmbeddedParameters.class);
            if (!embeddedParameters.nullAllowed())
                ((AggregateObjectMapping) mapping).setIsNullAllowed(false);
        }
    }
}
Also used : EmbeddedParameters(com.haulmont.cuba.core.entity.annotation.EmbeddedParameters) Field(java.lang.reflect.Field) AggregateObjectMapping(org.eclipse.persistence.mappings.AggregateObjectMapping) ClassDescriptor(org.eclipse.persistence.descriptors.ClassDescriptor) DatabaseMapping(org.eclipse.persistence.mappings.DatabaseMapping)

Aggregations

AggregateObjectMapping (org.eclipse.persistence.mappings.AggregateObjectMapping)21 DirectToFieldMapping (org.eclipse.persistence.mappings.DirectToFieldMapping)10 RelationalDescriptor (org.eclipse.persistence.descriptors.RelationalDescriptor)8 ClassDescriptor (org.eclipse.persistence.descriptors.ClassDescriptor)5 TransparentIndirectionPolicy (org.eclipse.persistence.internal.indirection.TransparentIndirectionPolicy)5 MappedKeyMapContainerPolicy (org.eclipse.persistence.internal.queries.MappedKeyMapContainerPolicy)5 DatabaseMapping (org.eclipse.persistence.mappings.DatabaseMapping)5 DatabaseField (org.eclipse.persistence.internal.helper.DatabaseField)4 ArrayList (java.util.ArrayList)3 Vector (java.util.Vector)3 VersionLockingPolicy (org.eclipse.persistence.descriptors.VersionLockingPolicy)2 DatabaseTable (org.eclipse.persistence.internal.helper.DatabaseTable)2 Association (org.eclipse.persistence.mappings.Association)2 OneToManyMapping (org.eclipse.persistence.mappings.OneToManyMapping)2 UnidirectionalOneToManyMapping (org.eclipse.persistence.mappings.UnidirectionalOneToManyMapping)2 ObjectTypeConverter (org.eclipse.persistence.mappings.converters.ObjectTypeConverter)2 Test (org.junit.Test)2 EmbeddedParameters (com.haulmont.cuba.core.entity.annotation.EmbeddedParameters)1 EmbeddedParameters (io.jmix.core.entity.annotation.EmbeddedParameters)1 MetaClass (io.jmix.core.metamodel.model.MetaClass)1