• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Projections类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.querydsl.core.types.Projections的典型用法代码示例。如果您正苦于以下问题:Java Projections类的具体用法?Java Projections怎么用?Java Projections使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Projections类属于com.querydsl.core.types包,在下文中一共展示了Projections类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: listWorkSchemes

import com.querydsl.core.types.Projections; //导入依赖的package包/类
private Collection<SchemeDTO> listWorkSchemes() {
  return querydslSupport.execute((connection, configuration) -> {
    QWorkScheme qWorkScheme = QWorkScheme.workScheme;
    return new SQLQuery<SchemeDTO>(connection, configuration)
        .select(Projections.fields(SchemeDTO.class, qWorkScheme.workSchemeId.as("schemeId"),
            qWorkScheme.name.as("name")))
        .from(qWorkScheme)
        .where(qWorkScheme.scope.eq(WORK_SCHEME_SCOPE_GLOBAL))
        .orderBy(qWorkScheme.name.asc())
        .fetch();
  });
}
 
开发者ID:everit-org,项目名称:jira-hr-admin,代码行数:13,代码来源:WorkSchemesServlet.java


示例2: shouldProject

import com.querydsl.core.types.Projections; //导入依赖的package包/类
@Test
public void shouldProject() {

    // given
    Person johnDoe = new Person("John", "Doe");
    repository.save(johnDoe);

    // when
    List<PersonProjection> actual = repository.query(query -> query
            .select(Projections.constructor(PersonProjection.class, person.firstName,
                                            person.lastName))
            .from(person)
            .fetch());

    // then
    then(actual).containsExactly(new PersonProjection(johnDoe.getFirstName(), johnDoe.getLastName()));
}
 
开发者ID:infobip,项目名称:infobip-spring-data-jpa-querydsl,代码行数:18,代码来源:SqlServerQueryDslJpaRepositoryTest.java


示例3: fetchChanged

import com.querydsl.core.types.Projections; //导入依赖的package包/类
private List<HuntingClubAreaChangedExcelView.ExcelRow> fetchChanged(final @Nonnull GISZone zoneEntity) {
    final SQZonePalsta zonePalsta = new SQZonePalsta("zp");
    final SQPalstaalue pa1 = new SQPalstaalue("pa1"); // Current
    final SQPalstaalue pa2 = new SQPalstaalue("pa2"); // New

    final NumberPath<Integer> pathPalstaId = zonePalsta.palstaId;
    final NumberPath<Integer> pathPalstaIdNew = zonePalsta.newPalstaId;

    final NumberPath<Long> pathPalstaTunnus = zonePalsta.palstaTunnus;
    final NumberPath<Long> pathPalstaTunnusNew = zonePalsta.newPalstaTunnus;

    final NumberPath<Double> pathAreaDiff = zonePalsta.diffArea;
    final NumberExpression<Double> pathAreaSize = zonePalsta.geom.asMultiPolygon().area();

    return sqlQueryFactory
            .from(zonePalsta)
            .leftJoin(pa1).on(pa1.id.eq(pathPalstaId))
            .leftJoin(pa2).on(pa2.id.eq(pathPalstaIdNew))
            .where(zonePalsta.zoneId.eq(zoneEntity.getId())
                    .and(zonePalsta.isChanged.isTrue()))
            .select(Projections.constructor(HuntingClubAreaChangedExcelView.ExcelRow.class,
                    pathPalstaTunnus, pathPalstaTunnusNew,
                    pathAreaSize, pathAreaDiff))
            .orderBy(pathPalstaTunnus.asc(), pathPalstaId.asc())
            .fetch();
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:27,代码来源:HuntingClubAreaExcelFeature.java


示例4: getWeekdayWorks

import com.querydsl.core.types.Projections; //导入依赖的package包/类
private Set<WeekdayWorkDTO> getWeekdayWorks(final long workSchemeId) {

    List<WeekdayWorkDTO> resultSet = querydslSupport.execute((connection, configuration) -> {
      QWeekdayWork qWeekdayWork = QWeekdayWork.weekdayWork;
      return new SQLQuery<WeekdayWorkDTO>(connection, configuration)
          .select(
              Projections.fields(WeekdayWorkDTO.class, qWeekdayWork.weekdayWorkId,
                  qWeekdayWork.weekday, qWeekdayWork.startTime, qWeekdayWork.duration))
          .from(qWeekdayWork)
          .where(qWeekdayWork.workSchemeId.eq(workSchemeId))
          .fetch();
    });
    TreeSet<WeekdayWorkDTO> weekdayWorks = new TreeSet<WeekdayWorkDTO>(WEEKDAY_WORK_DTO_COMPARATOR);
    weekdayWorks.addAll(resultSet);

    return weekdayWorks;
  }
 
开发者ID:everit-org,项目名称:jira-hr-admin,代码行数:18,代码来源:WorkSchemesServlet.java


示例5: listPublicHolidays

import com.querydsl.core.types.Projections; //导入依赖的package包/类
private Collection<PublicHolidayDTO> listPublicHolidays(final long schemeId, final Integer year) {
  if (year == null) {
    return Collections.emptySet();
  }
  return querydslSupport.execute((connection, configuration) -> {
    QPublicHoliday qPublicHoliday = QPublicHoliday.publicHoliday;
    return new SQLQuery<PublicHolidayDTO>(connection, configuration)
        .select(Projections.fields(PublicHolidayDTO.class, qPublicHoliday.publicHolidayId,
            qPublicHoliday.date, qPublicHoliday.replacementDate, qPublicHoliday.description))
        .from(qPublicHoliday)
        .where(qPublicHoliday.holidaySchemeId.eq(schemeId).and(qPublicHoliday.date.year().eq(year)
            .or(qPublicHoliday.replacementDate.year().eq(year))))
        .orderBy(qPublicHoliday.date.asc())
        .fetch();
  });
}
 
开发者ID:everit-org,项目名称:jira-hr-admin,代码行数:17,代码来源:HolidaySchemesServlet.java


示例6: visit

import com.querydsl.core.types.Projections; //导入依赖的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);

}
 
开发者ID:vineey,项目名称:archelix-rsql,代码行数:22,代码来源:QuerydslSelectBuilder.java


示例7: multiSelect

import com.querydsl.core.types.Projections; //导入依赖的package包/类
@Test
public void multiSelect() {
    String rqlSelectExpression = "select(contact.company, contact.name, contact.age)";
    DefaultSelectParser selectParser = new DefaultSelectParser();
    Map<String, Path> mappings = ImmutableMap.<String, Path>builder()
            .put("contact.age", QContactDocument.contactDocument.age)
            .put("contact.name", QContactDocument.contactDocument.name)
            .put("contact.bday", QContactDocument.contactDocument.bday)
            .put("contact.company", QContactDocument.contactDocument.company)
            .build();

    Expression selectExpression = selectParser.parse(rqlSelectExpression, QuerydslSelectContext.withMapping(QContactDocument.contactDocument, mappings));

    assertNotNull(selectExpression);

    assertEquals(Projections.bean(QContactDocument.contactDocument,
            QContactDocument.contactDocument.company,
            QContactDocument.contactDocument.name,
            QContactDocument.contactDocument.age), selectExpression);
}
 
开发者ID:vineey,项目名称:archelix-rsql,代码行数:21,代码来源:QuerydslSelectContextTest.java


示例8: defaultSelect

import com.querydsl.core.types.Projections; //导入依赖的package包/类
@Test
public void defaultSelect() {
    String rqlSelect = "";
    DefaultSelectParser selectParser = new DefaultSelectParser();
    Map<String, Path> mappings = ImmutableMap.<String, Path>builder()
            .put("contact.age", QContactDocument.contactDocument.age)
            .put("contact.name", QContactDocument.contactDocument.name)
            .put("contact.bday", QContactDocument.contactDocument.bday)
            .put("contact.company", QContactDocument.contactDocument.company)
            .build();

    Expression selectExpression = selectParser.parse(rqlSelect, QuerydslSelectContext.withMapping(QContactDocument.contactDocument, mappings));

    assertNotNull(selectExpression);

    assertEquals(Projections.bean(QContactDocument.contactDocument,
            QContactDocument.contactDocument.age,
            QContactDocument.contactDocument.name,
            QContactDocument.contactDocument.bday,
            QContactDocument.contactDocument.company), selectExpression);
}
 
开发者ID:vineey,项目名称:archelix-rsql,代码行数:22,代码来源:QuerydslSelectContextTest.java


示例9: fetchWithoutGeometry

import com.querydsl.core.types.Projections; //导入依赖的package包/类
@Override
@Transactional(readOnly = true)
public List<GISZoneWithoutGeometryDTO> fetchWithoutGeometry(final Collection<Long> zoneIds) {
    if (zoneIds.isEmpty()) {
        return emptyList();
    }

    return new JPASQLQuery<>(entityManager, queryDslSqlTemplates)
            .from(SQZone.zone)
            .select(Projections.constructor(GISZoneWithoutGeometryDTO.class,
                    SQZone.zone.zoneId, SQZone.zone.sourceType, SQZone.zone.computedAreaSize,
                    SQZone.zone.waterAreaSize, SQZone.zone.modificationTime))
            .where(SQZone.zone.zoneId.in(zoneIds))
            .fetch();
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:16,代码来源:GISZoneRepositoryImpl.java


示例10: listHolidaySchemes

import com.querydsl.core.types.Projections; //导入依赖的package包/类
private Collection<SchemeDTO> listHolidaySchemes() {
  return querydslSupport.execute((connection, configuration) -> {
    QHolidayScheme qHolidayScheme = QHolidayScheme.holidayScheme;

    return new SQLQuery<SchemeDTO>(connection, configuration)
        .select(Projections.fields(SchemeDTO.class, qHolidayScheme.holidaySchemeId.as("schemeId"),
            qHolidayScheme.name.as("name")))
        .from(qHolidayScheme)
        .fetch();
  });
}
 
开发者ID:everit-org,项目名称:jira-hr-admin,代码行数:12,代码来源:HolidaySchemesServlet.java


示例11: singleSelect

import com.querydsl.core.types.Projections; //导入依赖的package包/类
@Test
public void singleSelect() {
    String rqlSelectExpression = "select(employee.number)";
    DefaultSelectParser selectParser = new DefaultSelectParser();
    Map<String, Path> mappings = ImmutableMap.<String, Path>builder()
            .put("employee.number", QEmployee.employee.employeeNumber)
            .build();

    Expression selectExpression = selectParser.parse(rqlSelectExpression, QuerydslSelectContext.withMapping(QEmployee.employee, mappings));
    assertNotNull(selectExpression);
    assertEquals(Projections.bean(QEmployee.employee, QEmployee.employee.employeeNumber), selectExpression);
}
 
开发者ID:vineey,项目名称:archelix-rsql,代码行数:13,代码来源:QuerydslSelectContextTest.java


示例12: countByAccountAndType

import com.querydsl.core.types.Projections; //导入依赖的package包/类
@Override
public List<CountByAccountAndType> countByAccountAndType(final Set<String> accountIds,
                                                         final Optional<DateTime> fromDate,
                                                         final Optional<DateTime> toDate,
                                                         final boolean resolved,
                                                         final boolean whitelisted) {
    final QViolationEntity qViolation = new QViolationEntity("v");
    final QViolationTypeEntity qType = new QViolationTypeEntity("t");


    final JPQLQuery<ViolationEntity> query = from(qViolation);
    query.join(qViolation.violationTypeEntity, qType);

    final Collection<Predicate> whereClause = newArrayList();

    if (!accountIds.isEmpty()) {
        whereClause.add(qViolation.accountId.in(accountIds));
    }

    fromDate.map(qViolation.created::after).ifPresent(whereClause::add);
    toDate.map(qViolation.created::before).ifPresent(whereClause::add);

    if (whitelisted) {
        whereClause.add(qViolation.ruleEntity.isNotNull());
    } else if (resolved) {
        whereClause.add(qViolation.comment.isNotNull());
        whereClause.add(qViolation.ruleEntity.isNull());
    } else {
        whereClause.add(qViolation.comment.isNull());
        whereClause.add(qViolation.ruleEntity.isNull());
    }

    query.where(allOf(whereClause));

    query.groupBy(qViolation.accountId, qType.id);
    query.orderBy(qViolation.accountId.asc(), qType.id.asc());

    return query.select(Projections.constructor(CountByAccountAndType.class, qViolation.accountId, qType.id, qViolation.id.count())).fetch();
}
 
开发者ID:zalando-stups,项目名称:fullstop,代码行数:40,代码来源:ViolationRepositoryImpl.java


示例13: getLibraryFilesByPredicate

import com.querydsl.core.types.Projections; //导入依赖的package包/类
public List<LibraryFile> getLibraryFilesByPredicate(Predicate predicate) {
    QLibraryFile libFile = QLibraryFile.LibraryFile;
    return queryFactory.select(Projections.bean(LibraryFile.class, libFile.all())).from(libFile).where(predicate).fetch();
}
 
开发者ID:MolaynoxX,项目名称:amperfi,代码行数:5,代码来源:LibraryDatabase.java


示例14: getUserHolidayAmounts

import com.querydsl.core.types.Projections; //导入依赖的package包/类
private QueryResultWithCount<UserHolidayAmountDTO> getUserHolidayAmounts(final String user,
    final boolean currentTimeRanges, final int pageIndex) {

  return querydslSupport.execute((connection, configuration) -> {
    QUserHolidayAmount qUserHolidayAmount = QUserHolidayAmount.userHolidayAmount;
    QCwdUser qUser = QCwdUser.cwdUser;
    QDateRange qDateRange = QDateRange.dateRange;
    SQLQuery<UserHolidayAmountDTO> query = new SQLQuery<>(connection, configuration);
    query.from(qUserHolidayAmount)
        .innerJoin(qUser).on(qUserHolidayAmount.userId.eq(qUser.id))
        .innerJoin(qDateRange).on(qUserHolidayAmount.dateRangeId.eq(qDateRange.dateRangeId));

    QAvatar qAvatar = AvatarUtil.joinAvatarToCwdUser(query, qUser, "avatar");

    Expression<Long> defaultAvatarId = ConstantImpl.create(AvatarUtil.DEFAULT_AVATAR_ID);

    query
        .select(Projections.fields(UserHolidayAmountDTO.class,
            qUserHolidayAmount.userHolidayAmountId, qUser.userName, qUser.displayName,
            qDateRange.startDate, qDateRange.endDateExcluded, qUserHolidayAmount.amount,
            qUserHolidayAmount.description,
            new Coalesce<>(Long.class, qAvatar.id, defaultAvatarId).as("avatarId"),
            qAvatar.owner.as("avatarOwner")));

    List<Predicate> predicates = new ArrayList<>();
    if (user != null) {
      predicates.add(qUser.userName.eq(user));
    }
    if (currentTimeRanges) {
      Date currentDate = new Date(new java.util.Date().getTime());
      predicates.add(
          qDateRange.startDate.loe(currentDate)
              .and(qDateRange.endDateExcluded.gt(currentDate)));
    }

    query.where(predicates.toArray(new Predicate[0]));

    long count = query.fetchCount();

    query.orderBy(qUser.userName.asc(), qDateRange.endDateExcluded.desc());
    query.limit(PAGE_SIZE);
    query.offset((pageIndex - 1) * PAGE_SIZE);

    List<UserHolidayAmountDTO> resultSet = query.fetch();

    return new QueryResultWithCount<>(resultSet, count);
  });
}
 
开发者ID:everit-org,项目名称:jira-hr-admin,代码行数:49,代码来源:UserHolidayAmountServlet.java


示例15: querySchemeUsers

import com.querydsl.core.types.Projections; //导入依赖的package包/类
private QueryResultWithCount<SchemeUserDTO> querySchemeUsers(final int pageIndex,
    final long schemeId, final String userName, final boolean currentTimeRanges) {
  return querydslSupport.execute((connection, configuration) -> {
    QDateRange qDateRange = QDateRange.dateRange;
    QCwdUser qCwdUser = QCwdUser.cwdUser;

    SQLQuery<SchemeUserDTO> query = new SQLQuery<>(connection, configuration);
    query.from(qUserSchemeEntityParameter.userSchemeEntityPath)
        .innerJoin(qDateRange)
        .on(qDateRange.dateRangeId.eq(qUserSchemeEntityParameter.dateRangeId))
        .innerJoin(qCwdUser).on(qCwdUser.id.eq(qUserSchemeEntityParameter.userId));

    QAvatar qAvatar = AvatarUtil.joinAvatarToCwdUser(query, qCwdUser, "avatar");

    List<Predicate> predicates = new ArrayList<>();
    predicates.add(qUserSchemeEntityParameter.userSchemeSchemeId.eq(schemeId));

    if (currentTimeRanges) {
      Date currentDate = new Date(new java.util.Date().getTime());
      predicates.add(qDateRange.startDate.loe(currentDate)
          .and(qDateRange.endDateExcluded.gt(currentDate)));
    }

    if (userName != null) {
      predicates.add(qCwdUser.userName.eq(userName));
    }

    Expression<Long> defaultAvatarId = ConstantImpl.create(AvatarUtil.DEFAULT_AVATAR_ID);

    StringExpression userDisplayNameExpression = qCwdUser.displayName.as("userDisplayName");
    query.select(Projections.fields(SchemeUserDTO.class,
        qUserSchemeEntityParameter.userSchemeId.as("userSchemeId"), qDateRange.dateRangeId,
        qCwdUser.userName, userDisplayNameExpression, qDateRange.startDate,
        qDateRange.endDateExcluded,
        new Coalesce<>(Long.class, qAvatar.id, defaultAvatarId).as("avatarId"),
        qAvatar.owner.as("avatarOwner")));

    query.where(predicates.toArray(new Predicate[0]));

    long count = query.fetchCount();

    query.orderBy(userDisplayNameExpression.asc(), qDateRange.startDate.desc());
    long offset = PAGE_SIZE * (pageIndex - 1);
    if (offset >= count) {
      offset = PAGE_SIZE * (count / PAGE_SIZE - 1);
      if (offset < 0) {
        offset = 0;
      }
    }

    List<SchemeUserDTO> resultSet;
    if (offset >= count) {
      resultSet = Collections.emptyList();
    } else {
      resultSet = query.limit(PAGE_SIZE).offset(offset).fetch();
    }

    QueryResultWithCount<SchemeUserDTO> result = new QueryResultWithCount<>(resultSet, count);
    return result;
  });
}
 
开发者ID:everit-org,项目名称:jira-hr-admin,代码行数:62,代码来源:SchemeUsersComponent.java


示例16: historyToPredictionMapping

import com.querydsl.core.types.Projections; //导入依赖的package包/类
private Expression<Prediction> historyToPredictionMapping() {
    return Projections.constructor(Prediction.class, qPredictionHistory.ts, qPredictionHistory.spacesAvailable);
}
 
开发者ID:HSLdevcom,项目名称:parkandrideAPI,代码行数:4,代码来源:PredictionDao.java



注:本文中的com.querydsl.core.types.Projections类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EnumeratorIntegerDescriptor类代码示例发布时间:2022-05-22
下一篇:
Java ApplicationStartDataPBImpl类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap