当前位置: 首页>>代码示例>>Java>>正文


Java JoinType类代码示例

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


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

示例1: findByWordAndPackageNo

import javax.persistence.criteria.JoinType; //导入依赖的package包/类
public Collection<ExtGraph> findByWordAndPackageNo(String word, int packageno) {

        Long pkg = new Long(packageno);
        CriteriaBuilder criteriaBuilder = getEntityManager().getCriteriaBuilder();
        CriteriaQuery<ExtGraph> criteriaQuery = criteriaBuilder.createQuery(ExtGraph.class
        );

        Root<ExtGraph> root = criteriaQuery.from(ExtGraph.class);
        Join<ExtGraph, Synset> synset = root.join("synset", JoinType.INNER);
        Join<Synset, Sense> sts = synset.join("sense", JoinType.LEFT);
        List<Predicate> criteriaList = new ArrayList<>();

        Predicate firstCondition = criteriaBuilder.equal(root.get("word"), word);
        criteriaList.add(firstCondition);

        Predicate secondCondition = criteriaBuilder.equal(root.get("packageno"), pkg);
        criteriaList.add(secondCondition);

        Predicate thirdCondition = criteriaBuilder.equal(sts.get("senseIndex"), 0);
        criteriaList.add(thirdCondition);

        criteriaQuery.where(criteriaBuilder.and(criteriaList.toArray(new Predicate[0])));
        final TypedQuery<ExtGraph> query = getEntityManager().createQuery(criteriaQuery);

        return query.getResultList();
    }
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:27,代码来源:ExtGraphRepository.java

示例2: main

import javax.persistence.criteria.JoinType; //导入依赖的package包/类
public static void main(String[] args) {
	EntityManagerFactory entityManagerFactory = Persistence
			.createEntityManagerFactory("pl.edu.bogdan.training.db.entity");
	EntityManager em = entityManagerFactory.createEntityManager();

	em.getTransaction().begin();
	
	CriteriaBuilder cb = em.getCriteriaBuilder();
	CriteriaQuery<User> cq = cb.createQuery(User.class);
	Root<User> from = cq.from(User.class);
	Join<User, Role> join = from.join("role", JoinType.LEFT);
	cq.where(cb.equal(join.get("name"), "ordinary"));
	TypedQuery<User> tq = em.createQuery(cq);
	List<User> users = tq.getResultList();
	for (User u : users) {
		System.out.println(u.getLastName());
	}
	
	em.getTransaction().commit();
	em.close();
	entityManagerFactory.close();
}
 
开发者ID:PawelBogdan,项目名称:BecomeJavaHero,代码行数:23,代码来源:App8.java

示例3: fetchUsedQuotas

import javax.persistence.criteria.JoinType; //导入依赖的package包/类
private Map<Long, Integer> fetchUsedQuotas() {
    final CriteriaBuilder builder = entityManager.getCriteriaBuilder();
    final CriteriaQuery<Tuple> query = builder.createTupleQuery();
    final Root<HarvestReport> root = query.from(HarvestReport.class);

    Join<Harvest, HarvestQuota> joinedQuotas = root.join(HarvestReport_.harvests).join(Harvest_.harvestQuota, JoinType.LEFT);
    Path<Long> quotaId = joinedQuotas.get(HarvestQuota_.id);

    Expression<Long> count = builder.count(root.get(HarvestReport_.id));

    Predicate onlyApproved = builder.equal(root.get(HarvestReport_.state), HarvestReport.State.APPROVED);
    Predicate quotaNotNull = builder.isNotNull(quotaId);

    CriteriaQuery<Tuple> q = query
            .multiselect(quotaId, count)
            .where(onlyApproved, quotaNotNull)
            .groupBy(quotaId);
    return map(entityManager.createQuery(q).getResultList());
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:20,代码来源:PublicHarvestSeasonFeature.java

示例4: findByHarvestSeasonAndRhy

import javax.persistence.criteria.JoinType; //导入依赖的package包/类
default HarvestQuota findByHarvestSeasonAndRhy(final long harvestSeasonId, final long rhyId) {
    return findOne((root, query, cb) -> {
        final Join<HarvestQuota, HarvestSeason> seasonToJoin = root.join(HarvestQuota_.harvestSeason, JoinType.LEFT);
        final Predicate harvestSeasonPredicate = cb.equal(seasonToJoin.get(HarvestSeason_.id), harvestSeasonId);

        final Join<HarvestQuota, HarvestArea> areaToJoin = root.join(HarvestQuota_.harvestArea, JoinType.LEFT);
        final SetJoin<HarvestArea, Riistanhoitoyhdistys> rhysToJoin = areaToJoin.join(HarvestArea_.rhys, JoinType.LEFT);
        final Predicate rhyPredicate = cb.equal(rhysToJoin.get(Organisation_.id), rhyId);

        return cb.and(harvestSeasonPredicate, rhyPredicate);
    });
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:13,代码来源:HarvestQuotaRepository.java

示例5: createPredicate

import javax.persistence.criteria.JoinType; //导入依赖的package包/类
private static Predicate createPredicate(Root<Occupation> root, CriteriaBuilder cb, OccupationContactSearchDTO dto) {
    final List<Predicate> predicates = Lists.newArrayList();

    final Join<Occupation, Organisation> organisationJoin = root.join(Occupation_.organisation, JoinType.LEFT);

    predicates.add(validNow(root, cb));
    predicates.add(byOrgType(cb, organisationJoin, dto.getOrganisationType()));
    if (dto.getAreaCode() != null) {
        predicates.add(byArea(cb, organisationJoin, dto.getAreaCode()));
    }
    if (dto.getRhyCode() != null) {
        predicates.add(cb.equal(organisationJoin.get(Organisation_.officialCode), dto.getRhyCode()));
    }
    if (dto.getOccupationType() != null) {
        predicates.add(cb.equal(root.get(Occupation_.occupationType), dto.getOccupationType()));
    }

    return cb.and(toArray(predicates));
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:20,代码来源:ContactSearchFeature.java

示例6: getByNaturalID

import javax.persistence.criteria.JoinType; //导入依赖的package包/类
private static Optional<MCRUser> getByNaturalID(EntityManager em, String userName, String realmId) {
    CriteriaBuilder cb = em.getCriteriaBuilder();
    CriteriaQuery<MCRUser> query = cb.createQuery(MCRUser.class);
    Root<MCRUser> users = query.from(MCRUser.class);
    users.fetch(MCRUser_.owner.getName(), JoinType.LEFT);
    try {
        return Optional
            .of(em
                .createQuery(query
                    .distinct(true)
                    .where(getUserRealmCriterion(cb, users, userName, realmId)))
                .getSingleResult());
    } catch (NoResultException e) {
        return Optional.empty();
    }
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:17,代码来源:MCRUserManager.java

示例7: getEntryCourseTableData

import javax.persistence.criteria.JoinType; //导入依赖的package包/类
@Override
public Object[][] getEntryCourseTableData(SearchFilter filter) throws ProcessingException {
  Long eventNr = ((SingleEventSearchFormData) filter.getFormData()).getEvent().getValue();

  CriteriaBuilder b = JPA.getCriteriaBuilder();
  CriteriaQuery<Object[]> selectQuery = b.createQuery(Object[].class);
  Root<RtCourse> course = selectQuery.from(RtCourse.class);
  Join<RtCourse, RtEventClass> joinEventClasses = course.join(RtCourse_.rtEventClasses, JoinType.LEFT);
  Join<RtEventClass, RtRace> joinRaces = joinEventClasses.join(RtEventClass_.rtRaces, JoinType.LEFT);

  selectQuery.select(b.array(course.get(RtCourse_.id).get(RtCourseKey_.courseNr), course.get(RtCourse_.shortcut), b.countDistinct(joinRaces.get(RtRace_.entryNr)), b.countDistinct(joinRaces.get(RtRace_.id).get(RtRaceKey_.raceNr)))).where(eventNr != null ? b.equal(joinRaces.get(RtRace_.eventNr), eventNr) : b.conjunction()).groupBy(course.get(RtCourse_.id).get(RtCourseKey_.courseNr), course.get(RtCourse_.shortcut));

  List<Object[]> list = JPA.createQuery(selectQuery).getResultList();

  List<Object[]> result = new ArrayList<>();
  for (Object[] row : list) {
    Object[] resultRow = new Object[5];
    resultRow[0] = 0L; // Force Summary Order to bottom
    resultRow[1] = row[0];
    resultRow[2] = row[1];
    resultRow[3] = row[2];
    resultRow[4] = row[3];
    result.add(resultRow);
  }
  return JPAUtility.convertList2Array(result);
}
 
开发者ID:innovad,项目名称:4mila-1.0,代码行数:27,代码来源:RegistrationsOutlineService.java

示例8: existsRaceWithStartTime

import javax.persistence.criteria.JoinType; //导入依赖的package包/类
@Override
public boolean existsRaceWithStartTime(Long[] startlistSettingNrs) throws ProcessingException {
  if (startlistSettingNrs == null || startlistSettingNrs.length == 0) {
    return false;
  }

  CriteriaBuilder b = JPA.getCriteriaBuilder();
  CriteriaQuery<Long> selectQuery = b.createQuery(Long.class);
  Root<RtParticipation> participation = selectQuery.from(RtParticipation.class);
  Join<RtParticipation, RtEventClass> joinEventClass = participation.join(RtParticipation_.rtEventClass, JoinType.INNER);
  Join<RtEventClass, RtCourse> joinCourse = joinEventClass.join(RtEventClass_.rtCourse, JoinType.LEFT);

  selectQuery.select(b.count(participation.get(RtParticipation_.id).get(RtParticipationKey_.clientNr)))
      .where(
          b.and(
              b.isNotNull(participation.get(RtParticipation_.startTime)),
              b.equal(participation.get(RtParticipation_.id).get(RtParticipationKey_.clientNr), ServerSession.get().getSessionClientNr()),
              b.or(joinCourse.get(RtCourse_.startlistSettingNr).in(Arrays.asList(startlistSettingNrs)),
                  joinEventClass.get(RtEventClass_.startlistSettingNr).in(Arrays.asList(startlistSettingNrs)))
              ));
  List<Long> result = JPA.createQuery(selectQuery).getResultList();
  if (result == null || result.isEmpty()) {
    return false;
  }
  return result.get(0) > 0;
}
 
开发者ID:innovad,项目名称:4mila-1.0,代码行数:27,代码来源:StartlistService.java

示例9: getMapTableData

import javax.persistence.criteria.JoinType; //导入依赖的package包/类
@Override
public List<RtMap> getMapTableData(Long eventNr) throws ProcessingException {
  CriteriaBuilder b = JPA.getCriteriaBuilder();
  CriteriaQuery<RtMap> select = b.createQuery(RtMap.class);
  Root<RtMap> rtmap = select.from(RtMap.class);

  List<Predicate> list = new ArrayList<>();
  Predicate restriction1 = b.equal(rtmap.get(RtMap_.key).get(RtMapKey_.clientNr), ServerSession.get().getSessionClientNr());
  list.add(restriction1);
  if (eventNr != null) {
    Join<RtMap, RtEventMap> joinEventMap = rtmap.join(RtMap_.rtEventMaps, JoinType.LEFT);
    Predicate restriction2 = b.equal(joinEventMap.get(RtEventMap_.id).get(RtEventMapKey_.eventNr), eventNr);
    list.add(restriction2);
  }

  select.where(b.and(list.toArray(new Predicate[list.size()])));

  return JPA.createQuery(select).getResultList();
}
 
开发者ID:innovad,项目名称:4mila-1.0,代码行数:20,代码来源:EventsOutlineService.java

示例10: getRankingClassesTableData

import javax.persistence.criteria.JoinType; //导入依赖的package包/类
@Override
public Object[][] getRankingClassesTableData(Long rankingNr) throws ProcessingException {
  CriteriaBuilder b = JPA.getCriteriaBuilder();
  CriteriaQuery<Object[]> selectQuery = b.createQuery(Object[].class);
  Root<RtRankingEvent> rankingEvent = selectQuery.from(RtRankingEvent.class);
  Join<RtRankingEvent, RtEvent> joinEvent = rankingEvent.join(RtRankingEvent_.rtEvent, JoinType.INNER);
  Join<RtEvent, RtEventClass> joinEventClass = joinEvent.join(RtEvent_.rtEventClasses, JoinType.INNER);

  Subquery<Long> numberOfEventsSubselect = selectQuery.subquery(Long.class);
  Root<RtRankingEvent> subroot = numberOfEventsSubselect.from(RtRankingEvent.class);
  numberOfEventsSubselect.select(b.count(subroot.get(RtRankingEvent_.id).get(RtRankingEventKey_.rankingNr))).where(b.and(b.equal(subroot.get(RtRankingEvent_.id).get(RtRankingEventKey_.rankingNr), rankingNr), b.equal(subroot.get(RtRankingEvent_.id).get(RtRankingEventKey_.clientNr), ServerSession.get().getSessionClientNr())));

  selectQuery.select(b.array(joinEventClass.get(RtEventClass_.id).get(RtEventClassKey_.classUid), b.count(rankingEvent.get(RtRankingEvent_.id).get(RtRankingEventKey_.eventNr)))).where(b.and(b.equal(rankingEvent.get(RtRankingEvent_.id).get(RtRankingEventKey_.rankingNr), rankingNr), b.equal(rankingEvent.get(RtRankingEvent_.id).get(RtRankingEventKey_.clientNr), ServerSession.get().getSessionClientNr()))).groupBy(joinEventClass.get(RtEventClass_.id).get(RtEventClassKey_.classUid)).having(b.equal(b.count(rankingEvent.get(RtRankingEvent_.id).get(RtRankingEventKey_.eventNr)), numberOfEventsSubselect));

  return JPAUtility.convertList2Array(JPA.createQuery(selectQuery).getResultList());
}
 
开发者ID:innovad,项目名称:4mila-1.0,代码行数:17,代码来源:EventsOutlineService.java

示例11: getCityTableData

import javax.persistence.criteria.JoinType; //导入依赖的package包/类
@Override
public Object[][] getCityTableData(CitySearchFormData formData) throws ProcessingException {
  CriteriaBuilder b = JPA.getCriteriaBuilder();
  CriteriaQuery<Object[]> selectQuery = b.createQuery(Object[].class);
  Root<RtCity> city = selectQuery.from(RtCity.class);
  Join<RtCity, RtCountry> joinCountry = city.join(RtCity_.rtCountry);
  Join<RtCity, RtAddress> joinAddress = city.join(RtCity_.rtAddresses, JoinType.LEFT);

  JPACityBoxSearchFormDataStatementBuilder builder = new JPACityBoxSearchFormDataStatementBuilder(city);
  builder.build(formData.getCityBox());

  selectQuery.select(b.array(city.get(RtCity_.id).get(RtCityKey_.cityNr), city.get(RtCity_.zip), city.get(RtCity_.name), city.get(RtCity_.areaUid), city.get(RtCity_.region), city.get(RtCity_.countryUid), joinCountry.get(RtCountry_.countryCode), b.count(joinAddress.get(RtAddress_.id).get(RtAddressKey_.addressNr)))).where(b.and(b.equal(city.get(RtCity_.id).get(RtCityKey_.clientNr), ServerSession.get().getSessionClientNr()), builder.getPredicate())).groupBy(city.get(RtCity_.id).get(RtCityKey_.cityNr), city.get(RtCity_.zip), city.get(RtCity_.name), city.get(RtCity_.areaUid), city.get(RtCity_.region), city.get(RtCity_.countryUid), joinCountry.get(RtCountry_.countryCode));

  List<Object[]> result = JPA.createQuery(selectQuery).getResultList();
  return JPAUtility.convertList2Array(result);
}
 
开发者ID:innovad,项目名称:4mila-1.0,代码行数:17,代码来源:SettingsOutlineService.java

示例12: isImported

import javax.persistence.criteria.JoinType; //导入依赖的package包/类
/**
 * A {@link Specification} to filter Drops that have been imported or not.
 *
 * @param imported {@code true} to get Drops that have been imported,
 * {@code false} to get Drops that have not yet been imported
 *
 * @return {@link Specification}
 */
public static SingleParamSpecification<Drop> isImported(final Boolean imported) {
    return new SingleParamSpecification<Drop>(imported) {
        @Override
        public Predicate toPredicate(Root<Drop> root, CriteriaQuery<?> query, CriteriaBuilder builder) {

            Predicate predicate;

            if (imported) {
                predicate = builder.and(builder.isNotNull(root.get(Drop_.lastImportedDate)),
                        builder.or(builder.isNull(root.get(Drop_.importFailed)), builder.isFalse(root.get(Drop_.importFailed))),
                        builder.isNotNull(root.get(Drop_.importPollableTask)),
                        builder.isNotNull(root.join(Drop_.importPollableTask, JoinType.LEFT).get(PollableTask_.finishedDate)));
            } else {
                predicate = builder.or(builder.isNull(root.get(Drop_.lastImportedDate)),
                        builder.isTrue(root.get(Drop_.importFailed)),
                        builder.isNull(root.get(Drop_.importPollableTask)),
                        builder.isNull(root.join(Drop_.importPollableTask, JoinType.LEFT).get(PollableTask_.finishedDate)));
            }

            return predicate;
        }
    };
}
 
开发者ID:box,项目名称:mojito,代码行数:32,代码来源:DropSpecification.java

示例13: filterSpecListToPredicate

import javax.persistence.criteria.JoinType; //导入依赖的package包/类
protected P filterSpecListToPredicate(MetaDataObject rootMeta, F root, FilterSpec fs, JoinType defaultPredicateJoinType) {
	if ((fs.getOperator() == FilterOperator.EQ || fs.getOperator() == FilterOperator.NEQ)
			&& fs.getValue() instanceof Collection && ((Collection<?>) fs.getValue()).size() > PARAM_LIMIT_FOR_ORACLE) {

		return filterLargeValueSets(fs, rootMeta, root, defaultPredicateJoinType);
	}
	else {
		if (fs.hasExpressions()) {
			return filterExpressions(fs, rootMeta, root, defaultPredicateJoinType);
		}

		else {
			return filterSimpleOperation(fs, rootMeta);
		}
	}
}
 
开发者ID:katharsis-project,项目名称:katharsis-framework,代码行数:17,代码来源:QueryFilterBuilder.java

示例14: filterExpressions

import javax.persistence.criteria.JoinType; //导入依赖的package包/类
private P filterExpressions(FilterSpec fs, MetaDataObject rootMeta, F root, JoinType defaultPredicateJoinType) {
	// and, or, not.
	if (fs.getOperator() == FilterOperator.NOT) {
		return backend.not(
				backend.and(filterSpecListToPredicateArray(rootMeta, root, fs.getExpression(), defaultPredicateJoinType)));
	}
	else if (fs.getOperator() == FilterOperator.AND) {
		return backend.and(filterSpecListToPredicateArray(rootMeta, root, fs.getExpression(), defaultPredicateJoinType));
	}
	else if (fs.getOperator() == FilterOperator.OR) {
		return backend.or(filterSpecListToPredicateArray(rootMeta, root, fs.getExpression(), defaultPredicateJoinType));
	}
	else {
		throw new IllegalArgumentException(fs.toString());
	}
}
 
开发者ID:katharsis-project,项目名称:katharsis-framework,代码行数:17,代码来源:QueryFilterBuilder.java

示例15: doJoin

import javax.persistence.criteria.JoinType; //导入依赖的package包/类
@Override
public Expression<?> doJoin(MetaAttribute targetAttr, JoinType joinType, Expression<?> parent) {
	if (targetAttr instanceof MetaComputedAttribute) {

		MetaComputedAttribute computedAttr = (MetaComputedAttribute) targetAttr;
		QuerydslExpressionFactory expressionFactory = (QuerydslExpressionFactory<?>) queryImpl.getComputedAttrs()
				.get(computedAttr);

		return expressionFactory.getExpression(parent, getQuery());
	}
	else {
		Expression<Object> expression = QuerydslUtils.get(parent, targetAttr.getName());
		querydslQuery.getMetadata().addJoin(QuerydslUtils.convertJoinType(joinType), expression);
		return expression;
	}
}
 
开发者ID:katharsis-project,项目名称:katharsis-framework,代码行数:17,代码来源:QuerydslQueryBackend.java


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