use of com.querydsl.jpa.impl.JPAQueryFactory in project tutorials by eugenp.
the class QueryDSLIntegrationTest method setUp.
@Before
public void setUp() {
em = emf.createEntityManager();
em.getTransaction().begin();
queryFactory = new JPAQueryFactory(em);
}
use of com.querydsl.jpa.impl.JPAQueryFactory in project querydsl by querydsl.
the class JPAQueryFactoryTest method setUp.
@Before
public void setUp() {
factoryMock = EasyMock.createMock(EntityManagerFactory.class);
mock = EasyMock.createMock(EntityManager.class);
Supplier<EntityManager> provider = () -> mock;
queryFactory = new JPAQueryFactory(JPQLTemplates.DEFAULT, provider);
queryFactory2 = queryFactory;
queryFactory3 = new JPAQueryFactory(provider);
}
use of com.querydsl.jpa.impl.JPAQueryFactory in project jeeshop by remibantos.
the class CatalogItemFinder method countAll.
public Long countAll(EntityPath<? extends CatalogItem> entityPath) {
QCatalogItem qCatalogItem = new QCatalogItem(entityPath);
JPAQuery query = new JPAQueryFactory(entityManager).selectFrom(qCatalogItem);
return query.fetchCount();
}
use of com.querydsl.jpa.impl.JPAQueryFactory in project jeeshop by remibantos.
the class CatalogItemFinder method findVisibleCatalogItems.
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);
mapCatalogItemChildrenPresentation(catalogItem, locale);
});
return results;
}
use of com.querydsl.jpa.impl.JPAQueryFactory in project jeeshop by remibantos.
the class CatalogItemFinder method findAll.
public <T extends CatalogItem> List<T> findAll(EntityPath<T> entityPath, Integer offset, Integer limit, String orderBy, Boolean isDesc, String locale) {
QCatalogItem qCatalogItem = new QCatalogItem(entityPath);
JPAQuery<T> query = new JPAQueryFactory(entityManager).selectFrom(entityPath);
addOffsetAndLimitToQuery(offset, limit, query, orderBy, isDesc, qCatalogItem);
List<T> catalogItems = query.fetch();
return locale != null ? catalogItems.stream().peek(c -> {
c.setLocalizedPresentation(locale);
mapCatalogItemChildrenPresentation(c, locale);
}).collect(Collectors.toList()) : catalogItems;
}
Aggregations