本文整理汇总了Java中com.querydsl.jpa.JPQLQuery类的典型用法代码示例。如果您正苦于以下问题:Java JPQLQuery类的具体用法?Java JPQLQuery怎么用?Java JPQLQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JPQLQuery类属于com.querydsl.jpa包,在下文中一共展示了JPQLQuery类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: clubHasMooseGroupsWithHuntingDays
import com.querydsl.jpa.JPQLQuery; //导入依赖的package包/类
@Override
@Transactional(readOnly = true)
public boolean clubHasMooseGroupsWithHuntingDays(final HuntingClub club) {
final QGroupHuntingDay groupHuntingDay = QGroupHuntingDay.groupHuntingDay;
final QHuntingClubGroup group = QHuntingClubGroup.huntingClubGroup;
final QGameSpecies species = QGameSpecies.gameSpecies;
final JPQLQuery<HuntingClubGroup> mooseGroups = JPAExpressions.selectFrom(group)
.join(group.species, species)
.where(group.parentOrganisation.eq(club),
species.officialCode.eq(GameSpecies.OFFICIAL_CODE_MOOSE));
return 0 < jpaQueryFactory.selectFrom(groupHuntingDay)
.where(groupHuntingDay.group.in(mooseGroups))
.fetchCount();
}
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:17,代码来源:GroupHuntingDayRepositoryImpl.java
示例2: getPermitIdToMooseHarvestReportExistsMapping
import com.querydsl.jpa.JPQLQuery; //导入依赖的package包/类
private Map<Long, Boolean> getPermitIdToMooseHarvestReportExistsMapping(final List<HarvestPermit> permits,
final int speciesCode,
final int huntingYear) {
final QHarvestPermitSpeciesAmount speciesAmount = QHarvestPermitSpeciesAmount.harvestPermitSpeciesAmount;
final QMooseHarvestReport report = QMooseHarvestReport.mooseHarvestReport;
final QGameSpecies species = QGameSpecies.gameSpecies;
final JPQLQuery<Object> mooseHarvestReportQuery = jpqlQueryFactory.select(Expressions.nullExpression())
.from(report)
.where(report.speciesAmount.eq(speciesAmount));
final Expression<Boolean> mooseHarvestReportExists = new CaseBuilder()
.when(mooseHarvestReportQuery.exists()).then(Expressions.constant(true))
.otherwise(Expressions.constant(false));
return jpqlQueryFactory.select(speciesAmount.harvestPermit.id, mooseHarvestReportExists)
.from(speciesAmount)
.join(speciesAmount.gameSpecies, species)
.where(speciesAmount.harvestPermit.in(permits),
species.officialCode.eq(speciesCode),
speciesAmount.validOnHuntingYear(huntingYear))
.transform(groupBy(speciesAmount.harvestPermit.id).as(mooseHarvestReportExists));
}
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:24,代码来源:MoosePermitStatisticsService.java
示例3: groupClubsWithMembersOtherThanContactPerson
import com.querydsl.jpa.JPQLQuery; //导入依赖的package包/类
@Override
public Map<Long, Set<Long>> groupClubsWithMembersOtherThanContactPerson() {
final QOccupation occupation = QOccupation.occupation;
final QOrganisation club = new QOrganisation("club");
final QOrganisation rhy = new QOrganisation("rhy");
final QOrganisation rka = new QOrganisation("rka");
final BooleanExpression isClubMember = occupation.occupationType.eq(OccupationType.SEURAN_JASEN);
final BooleanExpression isContactPerson = occupation.occupationType.eq(OccupationType.SEURAN_YHDYSHENKILO);
final JPQLQuery<Person> clubContactPersons = JPAExpressions.selectFrom(occupation)
.where(occupation.validAndNotDeleted().and(isContactPerson))
.select(occupation.person);
return queryFactory.from(occupation)
.join(occupation.organisation, club)
.join(club.parentOrganisation, rhy)
.join(rhy.parentOrganisation, rka)
.where(rka.id.eq(rkaId)
.and(occupation.validAndNotDeleted())
.and(isClubMember)
.and(occupation.person.notIn(clubContactPersons)))
.select(rhy.id, club.id)
.groupBy(rhy.id, club.id)
.transform(groupBy(rhy.id).as(set(club.id)));
}
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:27,代码来源:HuntingClubStatisticsRhyQueries.java
示例4: groupClubsWithMembersOtherThanContactPerson
import com.querydsl.jpa.JPQLQuery; //导入依赖的package包/类
@Override
public Map<Long, Set<Long>> groupClubsWithMembersOtherThanContactPerson() {
final QOccupation occupation = QOccupation.occupation;
final QOrganisation club = new QOrganisation("club");
final QOrganisation rhy = new QOrganisation("rhy");
final QOrganisation rka = new QOrganisation("rka");
final BooleanExpression isClubMember = occupation.occupationType.eq(OccupationType.SEURAN_JASEN);
final BooleanExpression isContactPerson = occupation.occupationType.eq(OccupationType.SEURAN_YHDYSHENKILO);
final JPQLQuery<Person> clubContactPersons = JPAExpressions.selectFrom(occupation)
.where(occupation.validAndNotDeleted().and(isContactPerson))
.select(occupation.person);
return queryFactory.from(occupation)
.join(occupation.organisation, club)
.join(club.parentOrganisation, rhy)
.join(rhy.parentOrganisation, rka)
.where(occupation.validAndNotDeleted()
.and(isClubMember)
.and(occupation.person.notIn(clubContactPersons)))
.select(rka.id, club.id)
.groupBy(rka.id, club.id)
.transform(groupBy(rka.id).as(set(club.id)));
}
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:26,代码来源:HuntingClubStatisticsRkaQueries.java
示例5: findActiveByParentOrganisation
import com.querydsl.jpa.JPQLQuery; //导入依赖的package包/类
@Override
@Transactional(readOnly = true)
public List<Occupation> findActiveByParentOrganisation(final Organisation parentOrganisation) {
Objects.requireNonNull(parentOrganisation, "organisation is null");
final QOccupation occupation = QOccupation.occupation;
final QOrganisation organisation = QOrganisation.organisation;
final JPQLQuery<Organisation> childOrganisations = JPAExpressions
.selectFrom(organisation).where(organisation.parentOrganisation.eq(parentOrganisation));
return jpqlQueryFactory.selectFrom(occupation)
.join(occupation.person).fetchJoin()
.join(occupation.organisation).fetchJoin()
.where(occupation.validAndNotDeleted(), occupation.organisation.in(childOrganisations))
.fetch();
}
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:18,代码来源:OccupationRepositoryImpl.java
示例6: applyGlobalSearch
import com.querydsl.jpa.JPQLQuery; //导入依赖的package包/类
/**
* Adds a global contains text filter on the provided attributes.
* WARNING: this creates a very inefficient query. If you have many entity
* instances to query, use instead an indexed text search solution for better
* performance.
* @param text the text to look for
* @param query
* @param globalSearchAttributes the list of attributes to perform the
* filter on
* @return the updated query
*/
protected JPQLQuery<T> applyGlobalSearch(String text, JPQLQuery<T> query,
Path<?>... globalSearchAttributes) {
if (text != null && !StringUtils.isEmpty(text) && globalSearchAttributes.length > 0) {
BooleanBuilder searchCondition = new BooleanBuilder();
for (int i = 0; i < globalSearchAttributes.length; i++) {
Path<?> path = globalSearchAttributes[i];
if (path instanceof StringPath) {
StringPath stringPath = (StringPath) path;
searchCondition.or(stringPath.containsIgnoreCase(text));
} else if (path instanceof NumberExpression) {
searchCondition.or(((NumberExpression<?>) path).like("%".concat(text).concat("%")));
}
}
return query.where(searchCondition);
}
return query;
}
开发者ID:DISID,项目名称:springlets,代码行数:29,代码来源:QueryDslRepositorySupportExt.java
示例7: listNextCheckingBatch
import com.querydsl.jpa.JPQLQuery; //导入依赖的package包/类
@Override
public List<ExternalLinkWrapper> listNextCheckingBatch(int batchSize, int minDelayBetweenTwoChecks) {
JPQLQuery<ExternalLinkWrapper> query = new JPAQuery<>(getEntityManager());
// Query to list the next <batchsize> URLs
// Must be a separate query, not a subquery, since JPQL doesn't support limit in subqueries
List<String> nextUrlsToCheckSubquery = listNextCheckingBatchUrls(batchSize, minDelayBetweenTwoChecks);
if (nextUrlsToCheckSubquery.isEmpty()) {
return Lists.newArrayListWithCapacity(0);
}
// Query to list the matching linkwrappers (may be more than <batchsize>)
query.from(qExternalLinkWrapper)
.where(qExternalLinkWrapper.url.lower().in(nextUrlsToCheckSubquery))
// Only links without the following statuses are to be checked
.where(qExternalLinkWrapper.status.notIn(ExternalLinkStatus.INACTIVES))
.orderBy(qExternalLinkWrapper.id.asc());
return query.fetch();
}
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:22,代码来源:ExternalLinkWrapperDaoImpl.java
示例8: getNextTaskForExecution
import com.querydsl.jpa.JPQLQuery; //导入依赖的package包/类
@Override
public QueuedTaskHolder getNextTaskForExecution(String taskType) {
Date now = new Date();
QQueuedTaskHolder qQueuedTask = QQueuedTaskHolder.queuedTaskHolder;
JPQLQuery<QueuedTaskHolder> query = new JPAQuery<QueuedTaskHolder>(getEntityManager());
query.from(qQueuedTask)
.where(qQueuedTask.taskType.eq(taskType)
.and(qQueuedTask.startDate.isNull())
.and(qQueuedTask.triggeringDate.isNull()
.or(qQueuedTask.triggeringDate.before(now))))
.orderBy(qQueuedTask.version.asc(), qQueuedTask.creationDate.asc());
List<QueuedTaskHolder> tasksForExecution = query.fetch();
if (tasksForExecution.isEmpty()) {
return null;
} else {
return tasksForExecution.get(0);
}
}
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:24,代码来源:QueuedTaskHolderDaoImpl.java
示例9: getStalledTask
import com.querydsl.jpa.JPQLQuery; //导入依赖的package包/类
@Override
public QueuedTaskHolder getStalledTask(String taskType, int executionTimeLimitInSeconds) {
Calendar timeLimit = Calendar.getInstance();
timeLimit.add(Calendar.SECOND, -executionTimeLimitInSeconds);
QQueuedTaskHolder qQueuedTask = QQueuedTaskHolder.queuedTaskHolder;
JPQLQuery<QueuedTaskHolder> query = new JPAQuery<QueuedTaskHolder>(getEntityManager());
query.from(qQueuedTask)
.where(qQueuedTask.startDate.isNotNull()
.and(qQueuedTask.taskType.eq(taskType))
.and(qQueuedTask.startDate.before(timeLimit.getTime())));
List<QueuedTaskHolder> stalledTasks = query.fetch();
if (stalledTasks.isEmpty()) {
return null;
} else {
return stalledTasks.get(0);
}
}
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:23,代码来源:QueuedTaskHolderDaoImpl.java
示例10: read
import com.querydsl.jpa.JPQLQuery; //导入依赖的package包/类
@ExtDirectMethod(STORE_READ)
@Transactional(readOnly = true)
public ExtDirectStoreResult<User> read(ExtDirectStoreReadRequest request) {
JPQLQuery<User> query = this.jpaQueryFactory.selectFrom(QUser.user);
if (!request.getFilters().isEmpty()) {
StringFilter filter = (StringFilter) request.getFilters().iterator().next();
BooleanBuilder bb = new BooleanBuilder();
bb.or(QUser.user.loginName.containsIgnoreCase(filter.getValue()));
bb.or(QUser.user.lastName.containsIgnoreCase(filter.getValue()));
bb.or(QUser.user.firstName.containsIgnoreCase(filter.getValue()));
bb.or(QUser.user.email.containsIgnoreCase(filter.getValue()));
query.where(bb);
}
query.where(QUser.user.deleted.isFalse());
QuerydslUtil.addPagingAndSorting(query, request, User.class, QUser.user);
QueryResults<User> searchResult = query.fetchResults();
return new ExtDirectStoreResult<>(searchResult.getTotal(),
searchResult.getResults());
}
开发者ID:ralscha,项目名称:eds-starter6-jpa,代码行数:25,代码来源:UserService.java
示例11: processQueryParameters
import com.querydsl.jpa.JPQLQuery; //导入依赖的package包/类
/**
* Check if some known parameter is setted in query definition and apply behaviour to query
* @param query Query
* @param configuration Query configuration
*/
@SuppressWarnings("rawtypes")
private static void processQueryParameters(JPQLQuery<?> query, QueryConfiguration configuration) {
ObjectUtils.argumentNotNull(query, "Query must be not null");
if (query instanceof AbstractJPAQuery) {
configuration.getParameter(JpaQueryHint.QUERY_PARAMETER_HINT, JpaQueryHint.class)
.ifPresent(p -> ((AbstractJPAQuery) query).setHint(p.getName(), p.getValue()));
configuration.getParameter(JpaDatastore.QUERY_PARAMETER_LOCK_MODE, LockModeType.class)
.ifPresent(p -> ((AbstractJPAQuery) query).setLockMode(p));
}
}
开发者ID:holon-platform,项目名称:holon-datastore-jpa-querydsl,代码行数:18,代码来源:QueryDSLUtils.java
示例12: copyAreas
import com.querydsl.jpa.JPQLQuery; //导入依赖的package包/类
@Transactional
public void copyAreas(final int fromYear, final int toYear) {
final QHuntingClubArea huntingClubArea = QHuntingClubArea.huntingClubArea;
final QHuntingClubArea nextYearArea = new QHuntingClubArea("nextYearArea");
final JPQLQuery<HuntingClub> clubsHavingAreaNextYear = JPAExpressions.selectFrom(nextYearArea)
.select(nextYearArea.club).distinct()
.where(nextYearArea.huntingYear.eq(toYear)
.and(nextYearArea.active.eq(true)));
final List<Long> areaIdsToCopy = queryFactory
.from(huntingClubArea)
.select(huntingClubArea.id)
.where(huntingClubArea.huntingYear.eq(fromYear)
.and(huntingClubArea.active.eq(true))
.and(huntingClubArea.club.notIn(clubsHavingAreaNextYear))
)
.fetch();
LOG.info(String.format("Going to copy from year %s to year %s areas: %s", fromYear, toYear, areaIdsToCopy));
areaIdsToCopy.stream()
.map(id -> new HuntingClubAreaCopyDTO(id, toYear, true))
.forEach(dto -> {
LOG.info("Copying area id:" + dto.getId());
feature.copyWithoutTransform(dto);
LOG.info("Copying area id:" + dto.getId() + " complete.");
});
LOG.info("Copying done.");
}
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:30,代码来源:CopyAreasFromHuntingYearToAnotherFeature.java
示例13: baseQuery
import com.querydsl.jpa.JPQLQuery; //导入依赖的package包/类
private JPQLQuery<Long> baseQuery(final long permitId,
final int speciesCode,
final QHarvestPermit permit,
final QHarvestPermitSpeciesAmount hpsa,
final QGameSpecies species,
final QHuntingClub club) {
return queryFactory.from(permit)
.join(permit.speciesAmounts, hpsa)
.join(hpsa.gameSpecies, species)
.join(permit.permitPartners, club)
.where(permit.id.eq(permitId), species.officialCode.eq(speciesCode))
.select(club.id);
}
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:15,代码来源:MoosePermitTodoFeature.java
示例14: getPermitZones
import com.querydsl.jpa.JPQLQuery; //导入依赖的package包/类
Map<Long, Map<String, Object>> getPermitZones(final HarvestPermit permit,
final int huntingYear,
final GameSpecies species) {
final QHarvestPermit harvestPermit = QHarvestPermit.harvestPermit;
final QHuntingClub huntingClub = QHuntingClub.huntingClub;
final QHuntingClubGroup huntingClubGroup = QHuntingClubGroup.huntingClubGroup;
final QHuntingClubArea huntingClubArea = QHuntingClubArea.huntingClubArea;
final QGISZone zone = QGISZone.gISZone;
final JPQLQuery<HuntingClub> permitPartnerClubs = JPAExpressions.selectFrom(harvestPermit)
.join(harvestPermit.permitPartners, huntingClub)
.where(harvestPermit.eq(permit))
.select(huntingClub);
return queryFactory
.from(huntingClubGroup)
.join(huntingClubGroup.parentOrganisation, huntingClub._super)
.join(huntingClubGroup.huntingArea, huntingClubArea)
.join(huntingClubArea.zone, zone)
.where(huntingClubGroup.harvestPermit.eq(permit),
huntingClub.in(permitPartnerClubs),
huntingClubGroup.species.eq(species),
huntingClubGroup.huntingYear.eq(huntingYear),
huntingClubArea.huntingYear.eq(huntingYear),
huntingClubArea.active.isTrue())
.select(zone.id,
huntingClub.id,
huntingClub.nameFinnish,
huntingClub.nameSwedish,
zone.computedAreaSize)
.distinct()
.fetch()
.stream()
.collect(toMap(tuple -> tuple.get(zone.id), tuple -> ImmutableMap.of(
GeoJSONConstants.PROPERTY_CLUB_NAME, LocalisedString.of(
tuple.get(huntingClub.nameFinnish), tuple.get(huntingClub.nameSwedish)).asMap(),
GeoJSONConstants.PROPERTY_HUNTING_CLUB_ID, tuple.get(huntingClub.id),
GeoJSONConstants.PROPERTY_AREA_SIZE, tuple.get(zone.computedAreaSize))));
}
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:40,代码来源:SharedPermitMapFeature.java
示例15: getHarvestForPermit
import com.querydsl.jpa.JPQLQuery; //导入依赖的package包/类
private List<Harvest> getHarvestForPermit(final HarvestPermit permit,
final int huntingYear,
final GameSpecies species) {
final QHarvestPermit harvestPermit = QHarvestPermit.harvestPermit;
final QHuntingClub huntingClub = QHuntingClub.huntingClub;
final QHuntingClubGroup huntingClubGroup = QHuntingClubGroup.huntingClubGroup;
final QGroupHuntingDay groupHuntingDay = QGroupHuntingDay.groupHuntingDay;
final QHarvest harvest = QHarvest.harvest;
final JPQLQuery<HuntingClub> permitPartnerClubs = JPAExpressions.selectFrom(harvestPermit)
.join(harvestPermit.permitPartners, huntingClub)
.where(harvestPermit.eq(permit))
.select(huntingClub);
// NOTE: Result should not contain duplicate Harvest,
// because Harvest can only be linked to single hunting group day
return queryFactory
.from(huntingClubGroup)
.join(huntingClubGroup.parentOrganisation, huntingClub._super)
.join(huntingClubGroup.huntingDays, groupHuntingDay)
.join(groupHuntingDay.harvests, harvest)
.where(huntingClubGroup.harvestPermit.eq(permit),
huntingClub.in(permitPartnerClubs),
huntingClubGroup.huntingYear.eq(huntingYear),
huntingClubGroup.species.eq(species))
.orderBy(harvest.pointOfTime.desc(), harvest.id.desc())
.select(huntingClub, harvest)
.fetch()
.stream()
.map(tuple -> {
final HuntingClub resultClub = Objects.requireNonNull(tuple.get(0, HuntingClub.class));
final Harvest resultHarvest = Objects.requireNonNull(tuple.get(1, Harvest.class));
resultHarvest.setHuntingClub(resultClub);
return resultHarvest;
})
.collect(toList());
}
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:39,代码来源:SharedPermitMapFeature.java
示例16: findAllAsSlice
import com.querydsl.jpa.JPQLQuery; //导入依赖的package包/类
@Override
public Slice<T> findAllAsSlice(final Predicate predicate, final Pageable page) {
final JPQLQuery<T> query = createQuery(predicate)
.select(path)
.offset(page.getOffset())
.limit(page.getPageSize() + 1);
return toSlice(querydsl.applySorting(page.getSort(), query).fetch(), page);
}
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:9,代码来源:BaseRepositoryImpl.java
示例17: queryPersonWithExistingOrPastOccupation
import com.querydsl.jpa.JPQLQuery; //导入依赖的package包/类
private static JPQLQuery<Person> queryPersonWithExistingOrPastOccupation(
final @Nonnull OccupationType occupationType,
final @Nonnull Riistanhoitoyhdistys rhy) {
final QOccupation qRhyOccupation = QOccupation.occupation;
return JPAExpressions
.select(qRhyOccupation.person)
.from(qRhyOccupation)
.where(qRhyOccupation.organisation.eq(rhy)
.and(qRhyOccupation.occupationType.eq(occupationType))
.and(qRhyOccupation.beginDate.isNull().or(qRhyOccupation.beginDate.loe(today())))
.and(qRhyOccupation.notDeleted()));
}
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:14,代码来源:JHTTrainingRepositoryImpl.java
示例18: setUp
import com.querydsl.jpa.JPQLQuery; //导入依赖的package包/类
/**
* Test setup, creates a new {@link QueryDslRepositorySupportExt} to use in the test methods.
*/
@Before
public void setUp() throws Exception {
support = new QueryDslRepositorySupportExt<Object>(Object.class) {
@Override
protected JPQLQuery<Object> applyPagination(Pageable pageable, JPQLQuery<Object> query) {
return query;
}
};
}
开发者ID:DISID,项目名称:springlets,代码行数:13,代码来源:QueryDslRepositorySupportExtTest.java
示例19: listActive
import com.querydsl.jpa.JPQLQuery; //导入依赖的package包/类
@Override
public List<ExternalLinkWrapper> listActive() {
JPQLQuery<ExternalLinkWrapper> query = new JPAQuery<>(getEntityManager());
query.from(qExternalLinkWrapper)
.where(qExternalLinkWrapper.status.notIn(ExternalLinkStatus.INACTIVES))
.orderBy(qExternalLinkWrapper.url.lower().asc());
return query.fetch();
}
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:11,代码来源:ExternalLinkWrapperDaoImpl.java
示例20: map
import com.querydsl.jpa.JPQLQuery; //导入依赖的package包/类
/**
* @deprecated Use <code>query.transform(GroupBy2.transformer(GroupBy.sortedMap(key, value, keyComparator)))</code>
*/
@Deprecated
public static <K, V> Map<K, V> map(JPQLQuery<?> query,
Expression<K> key, Comparator<? super K> keyComparator,
Expression<V> value) {
return query.transform(GroupBy2.transformer(GroupBy.sortedMap(key, value, keyComparator)));
}
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:10,代码来源:Expressions2.java
注:本文中的com.querydsl.jpa.JPQLQuery类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论