com.querydsl.jpa.impl.JPAQueryFactory Java Examples
The following examples show how to use
com.querydsl.jpa.impl.JPAQueryFactory.
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: DiscountFinder.java From jeeshop with Apache License 2.0 | 6 votes |
public List<Discount> findVisibleDiscounts(ApplicableTo applicableTo, String locale) { Date now = new Date(); List<Discount> results = new JPAQueryFactory(entityManager) .selectFrom(discount).where( discount.disabled.isFalse(), discount.endDate.after(now).or(discount.endDate.isNull()), discount.startDate.before(now).or(discount.startDate.isNull()), discount.applicableTo.eq(applicableTo), discount.voucherCode.isNull() ).fetch(); results.forEach((discount) -> discount.setLocalizedPresentation(locale)); return results; }
Example #2
Source File: DiscountFinder.java From jeeshop with Apache License 2.0 | 6 votes |
public List<Discount> findEligibleOrderDiscounts(String locale, Long completedOrderNumbers) { Date now = new Date(); List<Discount> results = new JPAQueryFactory(entityManager) .selectFrom(discount).where( discount.disabled.isFalse(), discount.endDate.after(now).or(discount.endDate.isNull()), discount.startDate.before(now).or(discount.startDate.isNull()), discount.applicableTo.eq(ApplicableTo.ORDER), discount.triggerRule.ne(Discount.Trigger.ORDER_NUMBER).or( discount.triggerValue.eq(completedOrderNumbers.doubleValue() + 1) ), discount.voucherCode.isNull() ) .fetch(); results.forEach((discount) -> discount.setLocalizedPresentation(locale)); return results; }
Example #3
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 #4
Source File: CatalogItemFinder.java From jeeshop with Apache License 2.0 | 6 votes |
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; }
Example #5
Source File: CatalogItemFinder.java From jeeshop with Apache License 2.0 | 5 votes |
public <T extends CatalogItem, P extends CatalogItem> List<P> findForeignHolder(EntityPath<P> hp, ListPath<T, ? extends SimpleExpression<T>> h, T c) { return new JPAQueryFactory(entityManager) .selectFrom(hp) .where(h.contains(c)) .fetch(); }
Example #6
Source File: CatalogItemFinder.java From jeeshop with Apache License 2.0 | 5 votes |
public Long countBySearchCriteria(EntityPath<? extends CatalogItem> entityPath, String searchCriteria) { QCatalogItem qCatalogItem = new QCatalogItem(entityPath); JPAQuery query = new JPAQueryFactory(entityManager) .selectFrom(qCatalogItem) .where(buildSearchPredicate(searchCriteria, qCatalogItem)); return query.fetchCount(); }
Example #7
Source File: OrderFinder.java From jeeshop with Apache License 2.0 | 5 votes |
public Long countUserCompletedOrders(User user) { return new JPAQueryFactory(entityManager) .selectFrom(order) .where( order.user.eq(user), order.status.notIn(OrderStatus.CREATED, OrderStatus.CANCELLED, OrderStatus.RETURNED)) .fetchCount(); }
Example #8
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 #9
Source File: QuerydslQueryBackend.java From crnk-framework with Apache License 2.0 | 5 votes |
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); } }
Example #10
Source File: PermissionService.java From spring-boot-practice with Apache License 2.0 | 5 votes |
public List<Permission> findAllByRoleId(Integer id) { QPermission permission = QPermission.permission; QRolePermission rolePermission = QRolePermission.rolePermission; QRole role = QRole.role; return new JPAQueryFactory(em) .selectFrom(permission) .leftJoin(permission.rolePermission, rolePermission) .leftJoin(rolePermission.role, role) .where(role.id.eq(id)) .fetch(); }
Example #11
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 #12
Source File: MailTemplateFinder.java From jeeshop with Apache License 2.0 | 5 votes |
public MailTemplate findByNameAndLocale(String name, String locale) { if (locale == null) { locale = DEFAULT_LOCALE; } return new JPAQueryFactory(entityManager) .selectFrom(mailTemplate).where( mailTemplate.name.eq(name) .and(mailTemplate.locale.eq(locale).or(mailTemplate.locale.startsWith(locale)))) .fetchOne(); }
Example #13
Source File: MailTemplateFinder.java From jeeshop with Apache License 2.0 | 5 votes |
public List<MailTemplate> findByName(String name) { return new JPAQueryFactory(entityManager) .selectFrom(mailTemplate).where( mailTemplate.name.startsWith(name)) .fetch(); }
Example #14
Source File: QuerydslQueryBackend.java From katharsis-framework with Apache License 2.0 | 5 votes |
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); } }
Example #15
Source File: OrderFinder.java From jeeshop with Apache License 2.0 | 4 votes |
public Long countAll(String searchCriteria, OrderStatus status, Long skuId) { JPAQuery<Order> query = new JPAQueryFactory(entityManager).selectFrom(order) .where(matchesSearchAndStatusAndItemsSkuId(searchCriteria, status, skuId)); return query.fetchCount(); }
Example #16
Source File: CatalogItemFinder.java From jeeshop with Apache License 2.0 | 4 votes |
public Long countAll(EntityPath<? extends CatalogItem> entityPath) { QCatalogItem qCatalogItem = new QCatalogItem(entityPath); JPAQuery query = new JPAQueryFactory(entityManager).selectFrom(qCatalogItem); return query.fetchCount(); }
Example #17
Source File: JandyApplicationServer.java From jandy with GNU General Public License v3.0 | 4 votes |
@Bean public JPAQueryFactory jpaQueryFactory(Provider<EntityManager> em) { return new JPAQueryFactory(em); }
Example #18
Source File: QuerydslQueryBackend.java From katharsis-framework with Apache License 2.0 | 4 votes |
@Override public JPAQueryFactory getQueryFactory() { return queryImpl.getQueryFactory(); }
Example #19
Source File: GenericDAO.java From commafeed with Apache License 2.0 | 4 votes |
protected JPAQueryFactory query() { return factory; }
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; }
Example #21
Source File: RoleFinder.java From jeeshop with Apache License 2.0 | 4 votes |
public Role findByName(RoleName name) { return new JPAQueryFactory(entityManager) .selectFrom(role).where( role.name.eq(name)) .fetchOne(); }
Example #22
Source File: UserFinder.java From jeeshop with Apache License 2.0 | 4 votes |
public User findByLogin(String login) { return new JPAQueryFactory(entityManager) .selectFrom(user).where( user.login.eq(login)) .fetchOne(); }
Example #23
Source File: UserFinder.java From jeeshop with Apache License 2.0 | 4 votes |
public Long countAll() { return new JPAQueryFactory(entityManager) .selectFrom(user) .fetchCount(); }
Example #24
Source File: UserFinder.java From jeeshop with Apache License 2.0 | 4 votes |
public Long countBySearchCriteria(String searchCriteria) { JPAQuery<User> query = new JPAQueryFactory(entityManager).selectFrom(user) .where(buildSearchPredicate(searchCriteria)); return query.fetchCount(); }
Example #25
Source File: MailTemplateFinder.java From jeeshop with Apache License 2.0 | 4 votes |
public Long countAll() { JPAQuery query = new JPAQueryFactory(entityManager).selectFrom(mailTemplate); return query.fetchCount(); }
Example #26
Source File: QueryDSLIntegrationTest.java From tutorials with MIT License | 4 votes |
@Before public void setUp() { em = emf.createEntityManager(); em.getTransaction().begin(); queryFactory = new JPAQueryFactory(em); }
Example #27
Source File: GenericDAO.java From commafeed with Apache License 2.0 | 4 votes |
protected GenericDAO(SessionFactory sessionFactory) { super(sessionFactory); this.factory = new JPAQueryFactory(() -> currentSession()); }
Example #28
Source File: JPAQueryConfig.java From ZTuoExchange_framework with MIT License | 4 votes |
@Bean public JPAQueryFactory getJPAQueryFactory(EntityManager entityManager){ return new JPAQueryFactory(entityManager); }
Example #29
Source File: QueryDslConfig.java From ZTuoExchange_framework with MIT License | 4 votes |
@Bean public JPAQueryFactory getJPAQueryFactory(EntityManager entityManager){ return new JPAQueryFactory(entityManager); }
Example #30
Source File: JPAQueryConfig.java From ZTuoExchange_framework with MIT License | 4 votes |
@Bean public JPAQueryFactory getJPAQueryFactory(EntityManager entityManager){ return new JPAQueryFactory(entityManager); }