io.crnk.jpa.internal.query.backend.querydsl.QuerydslQueryImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of crnk-jpa Show documentation
Show all versions of crnk-jpa Show documentation
JSON API framework for Java
package io.crnk.jpa.internal.query.backend.querydsl;
import com.querydsl.jpa.impl.JPAQueryFactory;
import io.crnk.jpa.internal.query.AbstractJpaQueryImpl;
import io.crnk.jpa.internal.query.ComputedAttributeRegistryImpl;
import io.crnk.jpa.query.querydsl.QuerydslQuery;
import io.crnk.jpa.query.querydsl.QuerydslTranslationInterceptor;
import io.crnk.meta.provider.MetaPartition;
import javax.persistence.EntityManager;
import java.util.List;
import java.util.Map;
public class QuerydslQueryImpl extends AbstractJpaQueryImpl> implements QuerydslQuery {
private JPAQueryFactory queryFactory;
private List translationInterceptors;
public QuerydslQueryImpl(MetaPartition metaPartition, EntityManager em, Class clazz, ComputedAttributeRegistryImpl computedAttrs,
List translationInterceptors) {
super(metaPartition, em, clazz, computedAttrs);
this.translationInterceptors = translationInterceptors;
queryFactory = new JPAQueryFactory(em);
}
public QuerydslQueryImpl(MetaPartition metaPartition, EntityManager em, Class> clazz, ComputedAttributeRegistryImpl virtualAttrs,
List translationInterceptors, String attrName, List> entityIds) {
super(metaPartition, em, clazz, virtualAttrs, attrName, entityIds);
this.translationInterceptors = translationInterceptors;
queryFactory = new JPAQueryFactory(em);
}
@Override
public QuerydslExecutorImpl buildExecutor() {
return (QuerydslExecutorImpl) super.buildExecutor();
}
protected JPAQueryFactory getQueryFactory() {
return queryFactory;
}
@Override
protected QuerydslQueryBackend newBackend() {
return new QuerydslQueryBackend<>(this, clazz, parentMeta, parentAttr, parentIdSelection);
}
@Override
protected QuerydslExecutorImpl newExecutor(QuerydslQueryBackend ctx, int numAutoSelections,
Map selectionBindings) {
for (QuerydslTranslationInterceptor translationInterceptor : translationInterceptors) {
translationInterceptor.intercept(this, ctx);
}
return new QuerydslExecutorImpl<>(em, meta, ctx.getQuery(), numAutoSelections, selectionBindings);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy