Search in sources :

Example 1 with JpaCriteriaExpressionFactory

use of io.crnk.jpa.query.criteria.JpaCriteriaExpressionFactory in project crnk-framework by crnk-project.

the class JpaCriteriaQueryBackend method doJoin.

@SuppressWarnings("unchecked")
@Override
public From<?, ?> doJoin(MetaAttribute targetAttr, JoinType joinType, From<?, ?> parent) {
    if (targetAttr instanceof MetaComputedAttribute) {
        MetaComputedAttribute projAttr = (MetaComputedAttribute) targetAttr;
        @SuppressWarnings("rawtypes") JpaCriteriaExpressionFactory expressionFactory = (JpaCriteriaExpressionFactory<?>) queryImpl.getComputedAttrs().get(projAttr);
        return (From<?, ?>) expressionFactory.getExpression(parent, getCriteriaQuery());
    } else {
        return parent.join(targetAttr.getName(), joinType);
    }
}
Also used : JpaCriteriaExpressionFactory(io.crnk.jpa.query.criteria.JpaCriteriaExpressionFactory) MetaComputedAttribute(io.crnk.jpa.internal.query.MetaComputedAttribute)

Example 2 with JpaCriteriaExpressionFactory

use of io.crnk.jpa.query.criteria.JpaCriteriaExpressionFactory in project crnk-framework by crnk-project.

the class JpaCriteriaQueryBackend method getAttribute.

@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public Expression<?> getAttribute(Expression<?> currentCriteriaPath, MetaAttribute pathElement) {
    if (pathElement instanceof MetaComputedAttribute) {
        MetaComputedAttribute projAttr = (MetaComputedAttribute) pathElement;
        JpaCriteriaExpressionFactory expressionFactory = (JpaCriteriaExpressionFactory<?>) queryImpl.getComputedAttrs().get(projAttr);
        From from = (From) currentCriteriaPath;
        return expressionFactory.getExpression(from, getCriteriaQuery());
    } else {
        return ((Path<?>) currentCriteriaPath).get(pathElement.getName());
    }
}
Also used : MetaAttributePath(io.crnk.meta.model.MetaAttributePath) JpaCriteriaExpressionFactory(io.crnk.jpa.query.criteria.JpaCriteriaExpressionFactory) MetaComputedAttribute(io.crnk.jpa.internal.query.MetaComputedAttribute)

Aggregations

MetaComputedAttribute (io.crnk.jpa.internal.query.MetaComputedAttribute)2 JpaCriteriaExpressionFactory (io.crnk.jpa.query.criteria.JpaCriteriaExpressionFactory)2 MetaAttributePath (io.crnk.meta.model.MetaAttributePath)1