use of io.jmix.eclipselink.persistence.MappingProcessorContext in project jmix by jmix-framework.
the class JoinCriteriaMappingProcessor method process.
@Override
public void process(MappingProcessorContext context) {
DatabaseMapping mapping = context.getMapping();
Expression expression = beanFactory.getBeansOfType(JoinExpressionProvider.class).values().stream().map(provider -> provider.getJoinCriteriaExpression(mapping)).filter(Objects::nonNull).reduce(Expression::and).orElse(null);
// Applying additional join criteria, e.g. for soft delete or etc
if (mapping.isOneToManyMapping() || mapping.isOneToOneMapping()) {
// Apply expression to mappings
if (mapping.isOneToManyMapping()) {
((OneToManyMapping) mapping).setAdditionalJoinCriteria(expression);
} else if (mapping.isOneToOneMapping()) {
((OneToOneMapping) mapping).setAdditionalJoinCriteria(expression);
}
}
}
Aggregations