Java Code Examples for com.querydsl.jpa.impl.JPAQuery#fetch()
The following examples show how to use
com.querydsl.jpa.impl.JPAQuery#fetch() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MemberApplicationService.java From ZTuoExchange_framework with MIT License | 6 votes |
/** * 条件查询对象 pageNo pageSize 同时传时分页 * * @param predicateList * @param pageNo * @param pageSize * @return */ @Transactional(readOnly = true) public PageResult<MemberApplication> query(List<Predicate> predicateList, Integer pageNo, Integer pageSize) { List<MemberApplication> list; JPAQuery<MemberApplication> jpaQuery = queryFactory.selectFrom(memberApplication); if (predicateList != null) { jpaQuery.where(predicateList.toArray(new Predicate[predicateList.size()])); } jpaQuery.orderBy(memberApplication.createTime.desc()); if (pageNo != null && pageSize != null) { list = jpaQuery.offset((pageNo - 1) * pageSize).limit(pageSize).fetch(); } else { list = jpaQuery.fetch(); } return new PageResult<>(list, jpaQuery.fetchCount()); }
Example 2
Source File: OrderFinder.java From jeeshop with Apache License 2.0 | 6 votes |
public List<Order> findByUser(User user, Integer offset, Integer limit, String orderby, Boolean isDesc, OrderStatus status) { JPAQuery<Order> query = new JPAQueryFactory(entityManager).selectFrom(order) .where( order.user.eq(user), status != null && status.equals(OrderStatus.CREATED) ? null : order.status.ne(OrderStatus.CREATED), status != null ? order.status.eq(status) : null); if (offset != null) query.offset(offset); if (limit != null) query.limit(limit); sortBy(orderby, isDesc, query); return query.fetch(); }
Example 3
Source File: ExchangeOrderService.java From ZTuoExchange_framework with MIT License | 6 votes |
@Transactional(readOnly = true) public PageResult<ExchangeOrder> queryWhereOrPage(List<Predicate> predicates, Integer pageNo, Integer pageSize) { List<ExchangeOrder> list; JPAQuery<ExchangeOrder> jpaQuery = queryFactory.selectFrom(QExchangeOrder.exchangeOrder); if (predicates != null) { jpaQuery.where(predicates.toArray(new BooleanExpression[predicates.size()])); } jpaQuery.orderBy(QExchangeOrder.exchangeOrder.time.desc()); if (pageNo != null && pageSize != null) { list = jpaQuery.offset((pageNo - 1) * pageSize).limit(pageSize).fetch(); } else { list = jpaQuery.fetch(); } PageResult<ExchangeOrder> result = new PageResult<>(list, jpaQuery.fetchCount()); result.setNumber(pageNo); result.setSize(pageSize); return result; }
Example 4
Source File: OrderService.java From ZTuoExchange_framework with MIT License | 5 votes |
/** * 条件查询对象 pageNo pageSize 同时传时分页 * * @param predicateList * @param pageNo * @param pageSize * @return */ @Transactional(readOnly = true) public PageResult<Order> query(List<Predicate> predicateList, Integer pageNo, Integer pageSize) { List<Order> list; JPAQuery<Order> jpaQuery = queryFactory.selectFrom(QOrder.order); if (predicateList != null) { jpaQuery.where(predicateList.toArray(new Predicate[predicateList.size()])); } if (pageNo != null && pageSize != null) { list = jpaQuery.offset((pageNo - 1) * pageSize).limit(pageSize).fetch(); } else { list = jpaQuery.fetch(); } return new PageResult<>(list, jpaQuery.fetchCount()); }
Example 5
Source File: BaseService.java From ZTuoExchange_framework with MIT License | 5 votes |
/** * 查询列表 * * @param pageNo 分页参数 * @param pageSize 分页大小 * @param predicateList 查询条件 * @param entityPathBase 查询表 * @param orderSpecifierList 排序条件 * @return */ @Transactional(readOnly = true) public PageResult<T> queryDsl(Integer pageNo, Integer pageSize, List<Predicate> predicateList, EntityPathBase<T> entityPathBase, List<OrderSpecifier> orderSpecifierList) { List<T> list; //查询表 JPAQuery<T> jpaQuery = queryFactory.selectFrom(entityPathBase); //查询条件 if (predicateList != null && predicateList.size() > 0) { jpaQuery.where(predicateList.toArray(new Predicate[predicateList.size()])); } //排序方式 if (orderSpecifierList != null && orderSpecifierList.size() > 0) { jpaQuery.orderBy(orderSpecifierList.toArray(new OrderSpecifier[orderSpecifierList.size()])); } //分页查询 if (pageNo != null && pageSize != null) { list = jpaQuery.offset((pageNo - 1) * pageSize).limit(pageSize).fetch(); } else { list = jpaQuery.fetch(); } return new PageResult<>(list, pageNo, pageSize, jpaQuery.fetchCount()); }
Example 6
Source File: AdminAccessLogService.java From ZTuoExchange_framework with MIT License | 5 votes |
@Transactional(readOnly = true) public PageResult<AdminAccessLog> query(List<Predicate> predicateList, Integer pageNo, Integer pageSize) { List<AdminAccessLog> list; JPAQuery<AdminAccessLog> jpaQuery = queryFactory.selectFrom(QAdminAccessLog.adminAccessLog); if (predicateList != null && predicateList.size() > 0) { jpaQuery.where(predicateList.toArray(new Predicate[predicateList.size()])); } if (pageNo != null && pageSize != null) { list = jpaQuery.offset((pageNo - 1) * pageSize).limit(pageSize).fetch(); } else { list = jpaQuery.fetch(); } return new PageResult<>(list, jpaQuery.fetchCount());//添加总条数 }
Example 7
Source File: UserDaoImpl.java From artifact-listener with Apache License 2.0 | 5 votes |
@Override public List<User> listByUserGroup(UserGroup userGroup) { JPAQuery<User> query = new JPAQuery<>(getEntityManager()); QUser qUser = QUser.user; QUserGroup qUserGroup = QUserGroup.userGroup; query .select(qUser) .from(qUser) .join(qUser.groups, qUserGroup) .where(qUserGroup.eq(userGroup)) .orderBy(qUser.lastName.lower().asc(), qUser.firstName.lower().asc()); return query.fetch(); }
Example 8
Source File: ArtifactVersionDaoImpl.java From artifact-listener with Apache License 2.0 | 5 votes |
@Override public List<ArtifactVersion> listRecentReleases(int limit) { JPAQuery<ArtifactVersion> query = new JPAQuery<>(getEntityManager()); query.select(qArtifactVersion) .from(qArtifactVersion) .where(qArtifactVersion.artifact.deprecationStatus.eq(ArtifactDeprecationStatus.NORMAL)) .orderBy(qArtifactVersion.lastUpdateDate.desc()) .limit(limit); return query.fetch(); }
Example 9
Source File: ArtifactDaoImpl.java From artifact-listener with Apache License 2.0 | 5 votes |
@Override public List<Artifact> listMostFollowedArtifacts(int limit) { JPAQuery<Artifact> query = new JPAQuery<>(getEntityManager()); query .select(qArtifact) .from(qArtifact) .where(qArtifact.deprecationStatus.eq(ArtifactDeprecationStatus.NORMAL)) .orderBy(qArtifact.followersCount.desc()) .limit(limit); return query.fetch(); }
Example 10
Source File: MemberTransactionService.java From ZTuoExchange_framework with MIT License | 5 votes |
/** * 条件查询对象 pageNo pageSize 同时传时分页 * * @param booleanExpressionList * @param pageNo * @param pageSize * @return */ @Transactional(readOnly = true) public PageResult<MemberTransaction> queryWhereOrPage(List<BooleanExpression> booleanExpressionList, Integer pageNo, Integer pageSize) { List<MemberTransaction> list; JPAQuery<MemberTransaction> jpaQuery = queryFactory.selectFrom(QMemberTransaction.memberTransaction); if (booleanExpressionList != null) { jpaQuery.where(booleanExpressionList.toArray(new BooleanExpression[booleanExpressionList.size()])); } if (pageNo != null && pageSize != null) { list = jpaQuery.offset((pageNo - 1) * pageSize).limit(pageSize).fetch(); } else { list = jpaQuery.fetch(); } return new PageResult<>(list, jpaQuery.fetchCount()); }
Example 11
Source File: ArtifactVersionNotificationDaoImpl.java From artifact-listener with Apache License 2.0 | 5 votes |
@Override public List<ArtifactVersionNotification> listByArtifact(Artifact artifact) { JPAQuery<ArtifactVersionNotification> query = new JPAQuery<>(getEntityManager()); query.select(qArtifactVersionNotification) .from(qArtifactVersionNotification) .where(qArtifactVersionNotification.artifactVersion.artifact.eq(artifact)) .orderBy(qArtifactVersionNotification.creationDate.desc()); return query.fetch(); }
Example 12
Source File: UserFinder.java From jeeshop with Apache License 2.0 | 5 votes |
public List<User> findBySearchCriteria(String searchCriteria, Integer offset, Integer limit, String orderBy, Boolean isDesc) { JPAQuery<User> query = new JPAQueryFactory(entityManager).selectFrom(user) .where(buildSearchPredicate(searchCriteria)); if (offset != null) query.offset(offset); if (limit != null) query.limit(limit); sortBy(orderBy, isDesc, query); return query.fetch(); }
Example 13
Source File: CoinService.java From ZTuoExchange_framework with MIT License | 5 votes |
/** * 条件查询对象 pageNo pageSize 同时传时分页 * * @param booleanExpressionList * @param pageNo * @param pageSize * @return */ @Transactional(readOnly = true) public PageResult<Coin> query(List<BooleanExpression> booleanExpressionList, Integer pageNo, Integer pageSize) { List<Coin> list; JPAQuery<Coin> jpaQuery = queryFactory.selectFrom(QCoin.coin); if (booleanExpressionList != null) { jpaQuery.where(booleanExpressionList.toArray(new BooleanExpression[booleanExpressionList.size()])); } if (pageNo != null && pageSize != null) { list = jpaQuery.offset((pageNo - 1) * pageSize).limit(pageSize).fetch(); } else { list = jpaQuery.fetch(); } return new PageResult<>(list, jpaQuery.fetchCount());//添加总条数 }
Example 14
Source File: OrderService.java From ZTuoExchange_framework with MIT License | 5 votes |
/** * 条件查询对象 pageNo pageSize 同时传时分页 * * @param predicateList * @param pageNo * @param pageSize * @return */ @Transactional(readOnly = true) public PageResult<Order> query(List<Predicate> predicateList, Integer pageNo, Integer pageSize) { List<Order> list; JPAQuery<Order> jpaQuery = queryFactory.selectFrom(QOrder.order); if (predicateList != null) { jpaQuery.where(predicateList.toArray(new Predicate[predicateList.size()])); } if (pageNo != null && pageSize != null) { list = jpaQuery.offset((pageNo - 1) * pageSize).limit(pageSize).fetch(); } else { list = jpaQuery.fetch(); } return new PageResult<>(list, jpaQuery.fetchCount()); }
Example 15
Source File: WithdrawRecordService.java From ZTuoExchange_framework with MIT License | 5 votes |
/** * 条件查询对象 * * @param predicateList * @param pageNo * @param pageSize * @return */ @Transactional(readOnly = true) public PageResult<WithdrawRecord> query(List<Predicate> predicateList, Integer pageNo, Integer pageSize) { List<WithdrawRecord> list; JPAQuery<WithdrawRecord> jpaQuery = queryFactory.selectFrom(withdrawRecord); if (predicateList != null) { jpaQuery.where(predicateList.toArray(new Predicate[predicateList.size()])); } if (pageNo != null && pageSize != null) { list = jpaQuery.offset((pageNo - 1) * pageSize).limit(pageSize).fetch(); } else { list = jpaQuery.fetch(); } return new PageResult<>(list, jpaQuery.fetchCount()); }
Example 16
Source File: AdvertiseService.java From ZTuoExchange_framework with MIT License | 5 votes |
/** * 条件查询对象 pageNo pageSize 同时传时分页 * * @param booleanExpressionList * @param pageNo * @param pageSize * @return */ @Transactional(readOnly = true) public PageResult<Advertise> queryWhereOrPage(List<BooleanExpression> booleanExpressionList, Integer pageNo, Integer pageSize) { List<Advertise> list; JPAQuery<Advertise> jpaQuery = queryFactory.selectFrom(advertise); if (booleanExpressionList != null) { jpaQuery.where(booleanExpressionList.toArray(new BooleanExpression[booleanExpressionList.size()])); } if (pageNo != null && pageSize != null) { list = jpaQuery.offset((pageNo - 1) * pageSize).limit(pageSize).fetch(); } else { list = jpaQuery.fetch(); } return new PageResult<>(list, jpaQuery.fetchCount()); }
Example 17
Source File: WithdrawRecordService.java From ZTuoExchange_framework with MIT License | 5 votes |
/** * 条件查询对象 * * @param predicateList * @param pageNo * @param pageSize * @return */ @Transactional(readOnly = true) public PageResult<WithdrawRecord> query(List<Predicate> predicateList, Integer pageNo, Integer pageSize) { List<WithdrawRecord> list; JPAQuery<WithdrawRecord> jpaQuery = queryFactory.selectFrom(withdrawRecord); if (predicateList != null) { jpaQuery.where(predicateList.toArray(new Predicate[predicateList.size()])); } if (pageNo != null && pageSize != null) { list = jpaQuery.offset((pageNo - 1) * pageSize).limit(pageSize).fetch(); } else { list = jpaQuery.fetch(); } return new PageResult<>(list, jpaQuery.fetchCount()); }
Example 18
Source File: UserDaoImpl.java From artifact-listener with Apache License 2.0 | 5 votes |
@Override public List<ArtifactVersionNotification> listLastNotifications(User user, long limit) { JPAQuery<ArtifactVersionNotification> query = new JPAQuery<>(getEntityManager()); query .select(qArtifactVersionNotification) .from(qArtifactVersionNotification) .where(qArtifactVersionNotification.user.eq(user)) .orderBy(qArtifactVersionNotification.creationDate.desc()) .limit(limit); return query.fetch(); }
Example 19
Source File: CatalogItemFinder.java From jeeshop with Apache License 2.0 | 5 votes |
public <T extends CatalogItem> List<T> findBySearchCriteria(EntityPath<T> entityPath, String searchCriteria, Integer offset, Integer limit, String orderBy, Boolean isDesc) { QCatalogItem qCatalogItem = new QCatalogItem(entityPath); JPAQuery<T> query = new JPAQueryFactory(entityManager).selectFrom(entityPath) .where(buildSearchPredicate(searchCriteria, qCatalogItem)); addOffsetAndLimitToQuery(offset, limit, query, orderBy, isDesc, qCatalogItem); return query.fetch(); }
Example 20
Source File: OrderFinder.java From jeeshop with Apache License 2.0 | 4 votes |
public List<Order> findAll(Integer offset, Integer limit, String orderby, Boolean isDesc, String searchCriteria, OrderStatus status, Long skuId, boolean enhanceResult) { JPAQuery<Order> query = new JPAQueryFactory(entityManager).selectFrom(order) .where(matchesSearchAndStatusAndItemsSkuId(searchCriteria, status, skuId)); if (offset != null) query.offset(offset); if (limit != null) query.limit(limit); sortBy(orderby, isDesc, query); List<Order> orders = query.fetch(); if (enhanceResult) orders.forEach(this::enhanceOrder); return orders; }