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


Java Join类代码示例

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


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

示例1: getPlayersBySport

import javax.persistence.criteria.Join; //导入依赖的package包/类
public List<PlayerDetails> getPlayersBySport(String sport) {
    logger.info("getPlayersByLeagueId");
    List<Player> players = null;

    try {
        CriteriaQuery<Player> cq = cb.createQuery(Player.class);
        if (cq != null) {
            Root<Player> player = cq.from(Player.class);
            Join<Player, Team> team = player.join(Player_.teams);
            Join<Team, League> league = team.join(Team_.league);

            // Get MetaModel from Root
            //EntityType<Player> Player_ = player.getModel();

            // set the where clause
            cq.where(cb.equal(league.get(League_.sport), sport));
            cq.select(player).distinct(true);
            TypedQuery<Player> q = em.createQuery(cq);
            players = q.getResultList();
        }
        return copyPlayersToDetails(players);
    } catch (Exception ex) {
        throw new EJBException(ex);
    }
}
 
开发者ID:wwu-pi,项目名称:tap17-muggl-javaee,代码行数:26,代码来源:RequestBean.java

示例2: findByWordAndPackageNo

import javax.persistence.criteria.Join; //导入依赖的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

示例3: main

import javax.persistence.criteria.Join; //导入依赖的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

示例4: listByNetworkId

import javax.persistence.criteria.Join; //导入依赖的package包/类
public static List<SecurityGroup> listByNetworkId(EntityManager em, String sgId, String networkId) {

        // get Network or VM from port ID then Verify SGM ID and get GD ID...

        CriteriaBuilder cb = em.getCriteriaBuilder();

        CriteriaQuery<SecurityGroup> query = cb.createQuery(SecurityGroup.class);

        Root<SecurityGroup> root = query.from(SecurityGroup.class);
        Join<SecurityGroup, Object> join = root.join("securityGroupMembers");
        query = query.select(root)
                .distinct(true)
                .where(cb.and(
                        cb.equal(root.get("id"), sgId),
                        cb.equal(join.get("network").get("openstackId"), networkId)));

        return em.createQuery(query).getResultList();
    }
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:19,代码来源:SecurityGroupEntityMgr.java

示例5: findSalesList

import javax.persistence.criteria.Join; //导入依赖的package包/类
public List<Object[]> findSalesList(Date beginDate, Date endDate, Integer count) {
	CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
	CriteriaQuery<Object[]> criteriaQuery = criteriaBuilder.createQuery(Object[].class);
	Root<Product> product = criteriaQuery.from(Product.class);
	Join<Product, OrderItem> orderItems = product.join("orderItems");
	Join<Product, com.easyshopping.entity.Order> order = orderItems.join("order");
	criteriaQuery.multiselect(product.get("id"), product.get("sn"), product.get("name"), product.get("fullName"), product.get("price"), criteriaBuilder.sum(orderItems.<Integer> get("quantity")), criteriaBuilder.sum(criteriaBuilder.prod(orderItems.<Integer> get("quantity"), orderItems.<BigDecimal> get("price"))));
	Predicate restrictions = criteriaBuilder.conjunction();
	if (beginDate != null) {
		restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.greaterThanOrEqualTo(order.<Date> get("createDate"), beginDate));
	}
	if (endDate != null) {
		restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.lessThanOrEqualTo(order.<Date> get("createDate"), endDate));
	}
	restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.equal(order.get("orderStatus"), OrderStatus.completed), criteriaBuilder.equal(order.get("paymentStatus"), PaymentStatus.paid));
	criteriaQuery.where(restrictions);
	criteriaQuery.groupBy(product.get("id"), product.get("sn"), product.get("name"), product.get("fullName"), product.get("price"));
	criteriaQuery.orderBy(criteriaBuilder.desc(criteriaBuilder.sum(criteriaBuilder.prod(orderItems.<Integer> get("quantity"), orderItems.<BigDecimal> get("price")))));
	TypedQuery<Object[]> query = entityManager.createQuery(criteriaQuery).setFlushMode(FlushModeType.COMMIT);
	if (count != null && count >= 0) {
		query.setMaxResults(count);
	}
	return query.getResultList();
}
 
开发者ID:justinbaby,项目名称:my-paper,代码行数:25,代码来源:ProductDaoImpl.java

示例6: isSecurityGroupExistWithProtectAll

import javax.persistence.criteria.Join; //导入依赖的package包/类
public static boolean isSecurityGroupExistWithProtectAll(EntityManager em, String projectId, Long vcId) {
    CriteriaBuilder cb = em.getCriteriaBuilder();

    CriteriaQuery<SecurityGroup> query = cb.createQuery(SecurityGroup.class);

    Root<SecurityGroup> root = query.from(SecurityGroup.class);
    Join<SecurityGroup, Object> join = root.join("virtualizationConnector");
    query = query.select(root)
            .distinct(true)
            .where(cb.and(
                    cb.equal(root.get("projectId"), projectId),
                    cb.equal(root.get("protectAll"), true),
                    cb.equal(join.get("id"), vcId)));

    return !em.createQuery(query).setMaxResults(1).getResultList().isEmpty();
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:17,代码来源:SecurityGroupEntityMgr.java

示例7: getPlayersBySport

import javax.persistence.criteria.Join; //导入依赖的package包/类
public List<PlayerDetails> getPlayersBySport(String sport) {
    logger.info("getPlayersByLeagueId");
    List<Player> players = null;

    try {
        CriteriaQuery<Player> cq = cb.createQuery(Player.class);
        if (cq != null) {
            Root<Player> player = cq.from(Player.class);
            Join<Player, Team> team = player.join(Player_.team);
            Join<Team, League> league = team.join(Team_.league);

            // Get MetaModel from Root
            //EntityType<Player> Player_ = player.getModel();

            // set the where clause
            cq.where(cb.equal(league.get(League_.sport), sport));
            cq.select(player).distinct(true);
            TypedQuery<Player> q = em.createQuery(cq);
            players = q.getResultList();
        }
        return copyPlayersToDetails(players);
    } catch (Exception ex) {
        throw new EJBException(ex);
    }
}
 
开发者ID:wwu-pi,项目名称:tap17-muggl-javaee,代码行数:26,代码来源:RequestBeanQueries.java

示例8: getPath

import javax.persistence.criteria.Join; //导入依赖的package包/类
/**
 * Geef de Path voor de gegeven naam (kan punten bevatten om door objecten te lopen).
 *
 * @param base
 *            basis
 * @param naam
 *            naam
 * @param <T>
 *            attribuut type
 * @return path
 */
public static <T> Path<T> getPath(final Path<?> base, final String naam) {
    final Path<T> result;
    final int index = naam.indexOf('.');
    if (index == -1) {
        result = base.get(naam);
    } else {
        final String part = naam.substring(0, index);
        final String rest = naam.substring(index + 1);

        final Path<?> partPath = base.get(part);
        if (partPath.getModel() == null) {
            // Dan kunnen we hier niet door, maar moeten we via een join
            final Join<?, ?> join = ((From<?, ?>) base).join(part);
            result = getPath(join, rest);
        } else {
            result = getPath(partPath, rest);
        }
    }
    return result;
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:32,代码来源:PredicateBuilderUtil.java

示例9: countAllGroupByOwner

import javax.persistence.criteria.Join; //导入依赖的package包/类
@Override
public Map<Long, Long> countAllGroupByOwner() {
    CriteriaQuery<Tuple> query = criteriaBuilder.createTupleQuery();
    Root<DataFile> root = query.from(clazz);
    Join<DataFile, DataFileVersion> joinFileVersions = root.join(DataFile_.includedIn);
    Join<DataFileVersion, ContentVersion> joinVersion = joinFileVersions.join(DataFileVersion_.contentVersion);
    Join<ContentVersion, DigitalObject> joinObject = joinVersion.join(ContentVersion_.object);

    query.groupBy(joinObject.get(DigitalObject_.ownerId));
    query.multiselect(joinObject.get(DigitalObject_.ownerId), criteriaBuilder.countDistinct(root));

    Map<Long, Long> results = new HashMap<Long, Long>();
    for (Tuple tuple : entityManager.createQuery(query).getResultList()) {
        results.put((Long) tuple.get(0), (Long) tuple.get(1));
    }

    return results;
}
 
开发者ID:psnc-dl,项目名称:darceo,代码行数:19,代码来源:DataFileDaoBean.java

示例10: getStatusByGuardianEmail

import javax.persistence.criteria.Join; //导入依赖的package包/类
@GET
@Path("email/{guardianEmail}")
@Produces({"application/xml", "application/json"})
@RolesAllowed({"Guardian", "Administrator"})
public List<Student> getStatusByGuardianEmail(@PathParam("guardianEmail") String email) {
    logger.log(Level.INFO, "Principal is: {0}", ctx.getCallerPrincipal().getName());
    CriteriaQuery<Student> cq = cb.createQuery(Student.class);
    Root<Student> student = cq.from(Student.class);
    Join<Student, Guardian> guardian = student.join(Student_.guardians);

    cq.select(student);
    cq.where(cb.equal(guardian.get(Guardian_.email), email));
    cq.distinct(true);

    TypedQuery<Student> q = em.createQuery(cq);
    List<Student> results = q.getResultList();
    logger.log(Level.INFO, "Guardian {0}has {1} students.", new Object[]{email, results.size()});
    return results;
}
 
开发者ID:wwu-pi,项目名称:tap17-muggl-javaee,代码行数:20,代码来源:RequestBean.java

示例11: getStatusByGuardianId

import javax.persistence.criteria.Join; //导入依赖的package包/类
@GET
@Path("id/{guardianId}")
@Produces({"application/xml", "application/json"})
public List<Student> getStatusByGuardianId(@PathParam("guardianId") Long id) {
    logger.log(Level.INFO, "Principal is: {0}", ctx.getCallerPrincipal().getName());
    CriteriaQuery<Student> cq = cb.createQuery(Student.class);
    Root<Student> student = cq.from(Student.class);
    Join<Student, Guardian> guardian = student.join(Student_.guardians);

    cq.select(student);
    cq.where(cb.equal(guardian.get(Guardian_.id), id));
    cq.distinct(true);

    TypedQuery<Student> q = em.createQuery(cq);
    return q.getResultList();
}
 
开发者ID:wwu-pi,项目名称:tap17-muggl-javaee,代码行数:17,代码来源:RequestBean.java

示例12: getPlayersByLeagueId

import javax.persistence.criteria.Join; //导入依赖的package包/类
public List<PlayerDetails> getPlayersByLeagueId(String leagueId) {
    logger.info("getPlayersByLeagueId");
    List<Player> players = null;

    try {
        CriteriaQuery<Player> cq = cb.createQuery(Player.class);
        if (cq != null) {
            Root<Player> player = cq.from(Player.class);
            Join<Player, Team> team = player.join(Player_.teams);
            Join<Team, League> league = team.join(Team_.league);

            // Get MetaModel from Root
            //EntityType<Player> Player_ = player.getModel();

            // set the where clause
            cq.where(cb.equal(league.get(League_.id), leagueId));
            cq.select(player).distinct(true);
            TypedQuery<Player> q = em.createQuery(cq);
            players = q.getResultList();
        }
        return copyPlayersToDetails(players);
    } catch (Exception ex) {
        throw new EJBException(ex);
    }
}
 
开发者ID:wwu-pi,项目名称:tap17-muggl-javaee,代码行数:26,代码来源:RequestBean.java

示例13: getPlayersByLeagueId

import javax.persistence.criteria.Join; //导入依赖的package包/类
public List<PlayerDetails> getPlayersByLeagueId(String leagueId) {
    logger.info("getPlayersByLeagueId");
    List<Player> players = null;

    try {
        CriteriaQuery<Player> cq = cb.createQuery(Player.class);
        if (cq != null) {
            Root<Player> player = cq.from(Player.class);
            Join<Player, Team> team = player.join(Player_.team);
            Join<Team, League> league = team.join(Team_.league);

            // Get MetaModel from Root
            //EntityType<Player> Player_ = player.getModel();

            // set the where clause
            cq.where(cb.equal(league.get(League_.id), leagueId));
            cq.select(player).distinct(true);
            TypedQuery<Player> q = em.createQuery(cq);
            players = q.getResultList();
        }
        return copyPlayersToDetails(players);
    } catch (Exception ex) {
        throw new EJBException(ex);
    }
}
 
开发者ID:wwu-pi,项目名称:tap17-muggl-javaee,代码行数:26,代码来源:RequestBeanQueries.java

示例14: getPlayersByCity

import javax.persistence.criteria.Join; //导入依赖的package包/类
public List<PlayerDetails> getPlayersByCity(String city) {
    logger.info("getPlayersByCity");
    List<Player> players = null;

    try {
        CriteriaQuery<Player> cq = cb.createQuery(Player.class);
        if (cq != null) {
            Root<Player> player = cq.from(Player.class);
            Join<Player, Team> team = player.join(Player_.team);

            // Get MetaModel from Root
            //EntityType<Player> Player_ = player.getModel();

            // set the where clause
            cq.where(cb.equal(team.get(Team_.city), city));
            cq.select(player).distinct(true);
            TypedQuery<Player> q = em.createQuery(cq);
            players = q.getResultList();
        }
        return copyPlayersToDetails(players);
    } catch (Exception ex) {
        throw new EJBException(ex);
    }
}
 
开发者ID:wwu-pi,项目名称:tap17-muggl-javaee,代码行数:25,代码来源:RequestBeanQueries.java

示例15: fetchUsedQuotas

import javax.persistence.criteria.Join; //导入依赖的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


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