Example usage for javax.persistence.criteria From join

List of usage examples for javax.persistence.criteria From join

Introduction

In this page you can find the example usage for javax.persistence.criteria From join.

Prototype

<X, Y> Join<X, Y> join(String attributeName, JoinType jt);

Source Link

Document

Create a join to the specified attribute using the given join type.

Usage

From source file:org.jdal.dao.jpa.JpaUtils.java

/**
 * Copy Joins/*  w  w  w  . ja  va  2s. c o  m*/
 * @param from source Join
 * @param to destination Join
 */
public static void copyJoins(From<?, ?> from, From<?, ?> to) {
    for (Join<?, ?> j : from.getJoins()) {
        Join<?, ?> toJoin = to.join(j.getAttribute().getName(), j.getJoinType());
        toJoin.alias(getOrCreateAlias(j));

        copyJoins(j, toJoin);
    }

    for (Fetch<?, ?> f : from.getFetches()) {
        Fetch<?, ?> toFetch = to.fetch(f.getAttribute().getName());
        copyFetches(f, toFetch);

    }
}

From source file:com.zero.dao.impl.BaseDaoImpl.java

private void copyJoins(From<?, ?> from, From<?, ?> to) {
    for (Join<?, ?> join : from.getJoins()) {
        Join<?, ?> toJoin = to.join(join.getAttribute().getName(), join.getJoinType());
        toJoin.alias(getAlias(join));//from w  ww . j a  v  a 2s  .com
        copyJoins(join, toJoin);
    }
    for (Fetch<?, ?> fetch : from.getFetches()) {
        Fetch<?, ?> toFetch = to.fetch(fetch.getAttribute().getName());
        copyFetches(fetch, toFetch);
    }
}

From source file:org.easy.criteria.CriteriaComposer.java

/**
 * Creates all Singular or Set _joinContainer for this entity and all the
 * associated entities.//from  w  ww .j a  v  a2  s  .co m
 * 
 * @param root
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
protected void generateJoins(final From root) {
    this.root = root;
    Join<E, ?> join = null;

    if (_joins != null && _joins.size() > 0) {
        Set<Entry<JoinContainer<E>, CriteriaComposer<?>>> allSetJoins = _joins.entrySet();

        for (Entry<JoinContainer<E>, CriteriaComposer<?>> joinEntry : allSetJoins) {
            JoinContainer<E> joinContainer = joinEntry.getKey();

            if (joinContainer.setAttribute != null)
                join = root.join(joinContainer.setAttribute, joinContainer.joinType);

            else if (joinContainer.singularAttribute != null)
                join = root.join(joinContainer.singularAttribute, joinContainer.joinType);

            CriteriaComposer<?> subCriteria = joinEntry.getValue();

            if (subCriteria != null)
                subCriteria.generateJoins(join);
        }
    }
}

From source file:ru.savvy.jpafilterbuilder.FilterCriteriaBuilder.java

private Join reuseJoin(From<?, ?> path, String fieldName, boolean outer) {
    for (Join join : path.getJoins()) {
        if (join.getAttribute().getName().equals(fieldName)) {
            if ((join.getJoinType() == JoinType.LEFT) == outer) {
                logger.debug("Reusing existing join for field " + fieldName);
                return join;
            }//w w w.ja  v a2s.  c  om
        }
    }
    return outer ? path.join(fieldName, JoinType.LEFT) : path.join(fieldName);
}