Example usage for javax.persistence.criteria From getJoins

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

Introduction

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

Prototype

Set<Join<X, ?>> getJoins();

Source Link

Document

Return the joins that have been made from this bound type.

Usage

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

/**
 * Copy Joins// w  w w.  j a v  a  2 s. com
 * @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   ww w  . ja va 2  s.  com
        copyJoins(join, toJoin);
    }
    for (Fetch<?, ?> fetch : from.getFetches()) {
        Fetch<?, ?> toFetch = to.fetch(fetch.getAttribute().getName());
        copyFetches(fetch, toFetch);
    }
}

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;
            }//from  w w  w  .j ava2  s.co  m
        }
    }
    return outer ? path.join(fieldName, JoinType.LEFT) : path.join(fieldName);
}