當前位置: 首頁>>代碼示例>>Java>>正文


Java Root.join方法代碼示例

本文整理匯總了Java中javax.persistence.criteria.Root.join方法的典型用法代碼示例。如果您正苦於以下問題:Java Root.join方法的具體用法?Java Root.join怎麽用?Java Root.join使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.persistence.criteria.Root的用法示例。


在下文中一共展示了Root.join方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getPlayersBySport

import javax.persistence.criteria.Root; //導入方法依賴的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: byKeyword

import javax.persistence.criteria.Root; //導入方法依賴的package包/類
public static Specification<User> byKeyword(String keyword, String role, String active){
    return (Root<User> root, CriteriaQuery<?> query, CriteriaBuilder cb) -> {

        List<Predicate> predicates = new ArrayList<>();

        if (StringUtils.hasText(keyword)) {
            predicates.add(
                cb.or(
                    cb.like(root.get(User_.email), "%" + keyword + "%"),
                    cb.like(root.get(User_.username), "%" + keyword + "%")
                ));
        }

        if (StringUtils.hasText(role) && !"ALL".equals(role)) {

            ListJoin<User, String> roleJoin = root.join(User_.roles);
            predicates.add(cb.equal(roleJoin, role));
        }
        if (StringUtils.hasText(active)) {
            predicates.add(cb.equal(root.get(User_.active), Boolean.valueOf(active)));
        }
        return cb.and(predicates.toArray(new Predicate[predicates.size()]));
    };
}
 
開發者ID:hantsy,項目名稱:spring-microservice-sample,代碼行數:25,代碼來源:UserSpecifications.java

示例3: findByWordAndPackageNo

import javax.persistence.criteria.Root; //導入方法依賴的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

示例4: main

import javax.persistence.criteria.Root; //導入方法依賴的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

示例5: listByNetworkId

import javax.persistence.criteria.Root; //導入方法依賴的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

示例6: isSecurityGroupExistWithProtectAll

import javax.persistence.criteria.Root; //導入方法依賴的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.Root; //導入方法依賴的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: getStatusByGuardianEmail

import javax.persistence.criteria.Root; //導入方法依賴的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

示例9: getStatusByGuardianId

import javax.persistence.criteria.Root; //導入方法依賴的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

示例10: getPlayersByLeagueId

import javax.persistence.criteria.Root; //導入方法依賴的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

示例11: getPlayersByLeagueId

import javax.persistence.criteria.Root; //導入方法依賴的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

示例12: getPlayersByCity

import javax.persistence.criteria.Root; //導入方法依賴的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

示例13: hasSGMRemoved

import javax.persistence.criteria.Root; //導入方法依賴的package包/類
/**
 * @param em
 *            Hibernate EntityManager
 * @param sg
 *            Security Group
 * @return
 *         true if any SGM was deleted
 *         false if no SGM was deleted
 */
public static boolean hasSGMRemoved(EntityManager em, SecurityGroup sg) {
    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.equal(join.get("markedForDeletion"), true));

    return !em.createQuery(query).setMaxResults(1).getResultList().isEmpty();
}
 
開發者ID:opensecuritycontroller,項目名稱:osc-core,代碼行數:23,代碼來源:SecurityGroupEntityMgr.java

示例14: listByDeviceId

import javax.persistence.criteria.Root; //導入方法依賴的package包/類
public static List<SecurityGroup> listByDeviceId(EntityManager em, String sgId, String deviceId) {
    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("openstackId"), deviceId)));

    return em.createQuery(query).getResultList();
}
 
開發者ID:opensecuritycontroller,項目名稱:osc-core,代碼行數:16,代碼來源:SecurityGroupEntityMgr.java

示例15: getPlayersByCity

import javax.persistence.criteria.Root; //導入方法依賴的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_.teams);

            // 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,代碼來源:RequestBean.java


注:本文中的javax.persistence.criteria.Root.join方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。