List of usage examples for javax.persistence.criteria Join getJoinType
JoinType getJoinType();
From source file:org.jdal.dao.jpa.JpaUtils.java
/** * Find Joined Root of type clazz/*from ww w .j a va2s .c o m*/ * @param <T> * @param query the criteria query * @param rootClass the root class * @param joinClass the join class * @return the Join */ @SuppressWarnings("unchecked") public static <T, K> Join<T, K> findJoinedType(CriteriaQuery<T> query, Class<T> rootClass, Class<K> joinClass) { Root<T> root = findRoot(query, rootClass); Join<T, K> join = null; for (Join<T, ?> j : root.getJoins()) { if (j.getJoinType().equals(joinClass)) { join = (Join<T, K>) j; } } return join; }
From source file:org.jdal.dao.jpa.JpaUtils.java
/** * Copy Joins//from w w w . jav a 2 s . co 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 w w .j a v a2 s .c o m*/ 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; }/* www.j a v a 2 s . co m*/ } } return outer ? path.join(fieldName, JoinType.LEFT) : path.join(fieldName); }