本文整理汇总了Java中com.querydsl.core.types.EntityPath类的典型用法代码示例。如果您正苦于以下问题:Java EntityPath类的具体用法?Java EntityPath怎么用?Java EntityPath使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EntityPath类属于com.querydsl.core.types包,在下文中一共展示了EntityPath类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serialize
import com.querydsl.core.types.EntityPath; //导入依赖的package包/类
@Override
protected JPQLSerializer serialize(boolean forCountRow) {
// query target
if (getMetadata().getJoins() != null && !getMetadata().getJoins().isEmpty()) {
JoinExpression join = getMetadata().getJoins().get(0);
Expression<?> je = join.getTarget();
if (je != null && EntityPath.class.isAssignableFrom(je.getClass())) {
getQueryDefinition().setTarget(QueryDslTarget.of((EntityPath<?>) je));
}
}
QueryDSLUtils.configureQueryFromDefinition(this, getQueryDefinition(), null);
return super.serialize(forCountRow);
}
示例2: visit
import com.querydsl.core.types.EntityPath; //导入依赖的package包/类
@Override
public Expression visit(SelectNodeList node, QuerydslSelectParam selectParam) {
List<Expression> selectPath = new ArrayList<>();
Map<String, Path> mapping = selectParam.getMapping();
List<String> selectNodes = node.getFields();
if(selectNodes != null && !selectNodes.isEmpty()) {
for (String selectNode : selectNodes) {
Path path = mapping.get(selectNode);
selectPath.add(path);
}
}
EntityPath rootPath = selectParam.getRootPath();
Expression[] selectExpressionFields = selectNodes.isEmpty() ? mapping.values().toArray(new Expression[]{}) : selectPath.toArray(new Expression[]{});
return Projections.bean(rootPath, selectExpressionFields);
}
示例3: queryByPredicate
import com.querydsl.core.types.EntityPath; //导入依赖的package包/类
protected <T> JPAQuery<T> queryByPredicate(EntityPath<T> entityPath, Predicate predicate, Long limit, Long offset) {
JPAQuery<T> query = new JPAQuery<>(getEntityManager());
query.select(entityPath)
.from(entityPath);
if (predicate != null) {
query.where(predicate);
}
if (offset != null) {
query.offset(offset);
}
if (limit != null) {
query.limit(limit);
}
return query;
}
示例4: queryByField
import com.querydsl.core.types.EntityPath; //导入依赖的package包/类
/**
* @deprecated Utiliser QueryDSL
*/
@Deprecated
private <E extends GE, V extends Comparable<?>> Pair<EntityPath<E>, JPAQuery<E>> queryByField(Class<E> clazz, SingularAttribute<? super E, V> field, V fieldValue,
EnabledFilter enabledFilter) {
PathBuilder<E> pathBuilder = new PathBuilder<E>(clazz, "entityAlias");
QGenericLocalizedGenericListItem entityPath = new QGenericLocalizedGenericListItem(pathBuilder);
JPAQuery<E> query;
if (field != null) {
query = queryEntityByField(pathBuilder, field.getBindableJavaType(), field.getName(), fieldValue);
} else {
query = queryByPredicate(pathBuilder, null);
}
if (EnabledFilter.ENABLED_ONLY.equals(enabledFilter)) {
// l'appel au where ajoute la condition aux conditions précédentes
query = query.where(entityPath.enabled.isTrue());
}
return Pair.with((EntityPath<E>) pathBuilder, query);
}
示例5: queryByField
import com.querydsl.core.types.EntityPath; //导入依赖的package包/类
@Deprecated
private <E extends GenericListItem<?>, V extends Comparable<?>> Pair<EntityPath<E>, JPAQuery<E>> queryByField(Class<E> clazz, SingularAttribute<? super E, V> field, V fieldValue,
EnabledFilter enabledFilter) {
PathBuilder<E> pathBuilder = new PathBuilder<E>(clazz, "entityAlias");
QGenericListItem entityPath = new QGenericListItem(pathBuilder);
JPAQuery<E> query;
if (field != null) {
query = queryEntityByField(pathBuilder, field.getBindableJavaType(), field.getName(), fieldValue);
} else {
query = queryByPredicate(pathBuilder, null);
}
if (EnabledFilter.ENABLED_ONLY.equals(enabledFilter)) {
// l'appel au where ajoute la condition aux conditions précédentes
query = query.where(entityPath.enabled.isTrue());
}
return Pair.with((EntityPath<E>) pathBuilder, query);
}
示例6: findVisibleCatalogItems
import com.querydsl.core.types.EntityPath; //导入依赖的package包/类
public <T extends CatalogItem> List<T> findVisibleCatalogItems(EntityPath<T> entityPath, List<T> items, String locale) {
QCatalogItem qCatalogItem = new QCatalogItem(entityPath);
Date now = new Date();
List<T> results = new JPAQueryFactory(entityManager)
.selectFrom(entityPath).where(
qCatalogItem.disabled.isFalse(),
qCatalogItem.endDate.after(now).or(qCatalogItem.endDate.isNull()),
qCatalogItem.startDate.before(now).or(qCatalogItem.startDate.isNull()),
qCatalogItem.in(items)
)
.fetch();
results.forEach((catalogItem) -> catalogItem.setLocalizedPresentation(locale));
return results;
}
示例7: getEntityPath
import com.querydsl.core.types.EntityPath; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static <T> EntityPath<T> getEntityPath(Class<T> entityClass) {
Class<?> queryClass = getQueryClass(entityClass);
try {
String fieldName = firstToLower(entityClass.getSimpleName());
Field field = queryClass.getField(fieldName);
return (EntityPath<T>) field.get(entityClass);
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
throw new IllegalStateException("failed to access query class " + queryClass.getName(), e);
}
}
示例8: getEntityPath
import com.querydsl.core.types.EntityPath; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static <T> EntityPath<T> getEntityPath(Class<T> entityClass) {
Class<?> queryClass = getQueryClass(entityClass);
try {
String fieldName = firstToLower(entityClass.getSimpleName());
Field field = queryClass.getField(fieldName);
return (EntityPath<T>) field.get(entityClass);
}
catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
throw new IllegalStateException("failed to access query class " + queryClass.getName(), e);
}
}
示例9: QuerydslQueryBackend
import com.querydsl.core.types.EntityPath; //导入依赖的package包/类
public QuerydslQueryBackend(QuerydslQueryImpl<T> queryImpl, Class<T> clazz, MetaDataObject parentMeta,
MetaAttribute parentAttr, boolean addParentSelection) {
this.queryImpl = queryImpl;
JPAQueryFactory queryFactory = queryImpl.getQueryFactory();
if (parentMeta != null) {
parentFrom = QuerydslUtils.getEntityPath(parentMeta.getImplementationClass());
root = QuerydslUtils.getEntityPath(clazz);
Path joinPath = (Path) QuerydslUtils.get(parentFrom, parentAttr.getName());
joinHelper = new JoinRegistry<>(this, queryImpl);
joinHelper.putJoin(new MetaAttributePath(), root);
if (addParentSelection) {
Expression<Object> parentIdExpr = getParentIdExpression(parentMeta, parentAttr);
querydslQuery = queryFactory.select(parentIdExpr, root);
}
else {
querydslQuery = queryFactory.select(root);
}
querydslQuery = querydslQuery.from(parentFrom);
if (joinPath instanceof CollectionExpression) {
querydslQuery = querydslQuery.join((CollectionExpression) joinPath, root);
}
else {
querydslQuery = querydslQuery.join((EntityPath) joinPath, root);
}
}
else {
root = QuerydslUtils.getEntityPath(clazz);
joinHelper = new JoinRegistry<>(this, queryImpl);
joinHelper.putJoin(new MetaAttributePath(), root);
querydslQuery = queryFactory.select(root);
querydslQuery = querydslQuery.from((EntityPath) root);
}
}
示例10: withMapping
import com.querydsl.core.types.EntityPath; //导入依赖的package包/类
public static QuerydslSelectContext withMapping(EntityPath rootPath, Map<String, Path> mappings) {
return (QuerydslSelectContext) new QuerydslSelectContext()
.setSelectParam(new QuerydslSelectParam()
.setRootPath(rootPath)
.setMapping(mappings))
.setSelectBuilder(new QuerydslSelectBuilder());
}
示例11: list
import com.querydsl.core.types.EntityPath; //导入依赖的package包/类
protected <T extends E> List<T> list(EntityPath<T> entityPath, Long limit, Long offset) {
OrderSpecifier<?> order = null;
if (GenericEntity.class.isAssignableFrom(entityPath.getType())) {
// cast possible puisqu'on vient de vérifier le type de objectclass
@SuppressWarnings("unchecked")
QGenericEntity qGenericEntity = new QGenericEntity((Path<? extends GenericEntity<?, ?>>) (Object) entityPath);
order = qGenericEntity.id.asc();
}
return queryByPredicateOrdered(entityPath, null, limit, offset, order).fetch();
}
示例12: queryByPredicateOrdered
import com.querydsl.core.types.EntityPath; //导入依赖的package包/类
protected <T> JPAQuery<T> queryByPredicateOrdered(EntityPath<T> entityPath, Predicate predicate, Long limit, Long offset, OrderSpecifier<?>... orderSpecifiers) {
JPAQuery<T> query = queryByPredicate(entityPath, predicate, limit, offset);
if (orderSpecifiers != null && orderSpecifiers.length > 0) {
query.orderBy(orderSpecifiers);
}
return query;
}
示例13: listByField
import com.querydsl.core.types.EntityPath; //导入依赖的package包/类
/**
* @deprecated Utiliser QueryDSL
*/
@Deprecated
@Override
public <E extends GE, V extends Comparable<?>> List<E> listByField(Class<E> clazz, SingularAttribute<? super E, V> field, V fieldValue,
EnabledFilter enabledFilter, Comparator<? super E> comparator) {
Pair<EntityPath<E>, JPAQuery<E>> queryItem = queryByField(clazz, field, fieldValue, enabledFilter);
List<E> entities = queryItem.getValue1().fetch();
Collections.sort(entities, comparator);
return entities;
}
示例14: countByField
import com.querydsl.core.types.EntityPath; //导入依赖的package包/类
/**
* @deprecated Utiliser QueryDSL
*/
@Deprecated
@Override
public <E extends GE, V extends Comparable<?>> Long countByField(Class<E> clazz, SingularAttribute<? super E, V> field, V fieldValue,
EnabledFilter enabledFilter) {
Pair<EntityPath<E>, JPAQuery<E>> queryItem = queryByField(clazz, field, fieldValue, enabledFilter);
return queryItem.getValue1().distinct().fetchCount();
}
示例15: listByLocalizedLabel
import com.querydsl.core.types.EntityPath; //导入依赖的package包/类
@Override
public <E extends GE> List<E> listByLocalizedLabel(EntityPath<E> source, Locale locale, String label) {
JPQLQuery<E> query = new JPAQuery<E>(getEntityManager());
QGenericLocalizedGenericListItem qLocalizedGenericListItem = new QGenericLocalizedGenericListItem(source);
query.select(source)
.from(qLocalizedGenericListItem)
.where(qLabelTextPath(qLocalizedGenericListItem, locale).eq(label));
return query.fetch();
}