@SuppressWarnings({ "unchecked" }) private void renderFetches( StringBuilder jpaqlQuery, RenderingContext renderingContext, Collection<Fetch> fetches) { if ( fetches == null ) { return; } for ( Fetch fetch : fetches ) { ( (FromImplementor) fetch ).prepareAlias( renderingContext ); jpaqlQuery.append( renderJoinType( fetch.getJoinType() ) ) .append( "fetch " ) .append( ( (FromImplementor) fetch ).renderTableExpression( renderingContext ) ); renderFetches( jpaqlQuery, renderingContext, fetch.getFetches() ); } } }
@Override public Set<Fetch<X, ?>> getFetches() { return getWrapped().getFetches(); }
@SuppressWarnings("unchecked") protected void fetchToJoin(final From<?, ?> from, final Set<Fetch<?, ?>> fetches) { if (fetches != null && !fetches.isEmpty()) { for (final Fetch<?, ?> fetch : fetches) { @SuppressWarnings("rawtypes") final Join join = (Join) fetch; final Set<Fetch<?, ?>> fs = (Set<Fetch<?, ?>>) ((Set<?>) fetch.getFetches()); if (fs.isEmpty()) { try { from.getJoins().add(join); } catch (UnsupportedOperationException e) { } } else { fetchToJoin(join, fs); } } from.getFetches().clear(); } } }
@SuppressWarnings({ "unchecked" }) private void renderFetches( StringBuilder jpaqlQuery, CriteriaQueryCompiler.RenderingContext renderingContext, Collection<Fetch> fetches) { if ( fetches == null ) { return; } for ( Fetch fetch : fetches ) { ( (FromImplementor) fetch ).prepareAlias( renderingContext ); jpaqlQuery.append( renderJoinType( fetch.getJoinType() ) ) .append( "fetch " ) .append( ( (FromImplementor) fetch ).renderTableExpression( renderingContext ) ); renderFetches( jpaqlQuery, renderingContext, fetch.getFetches() ); } } }
private static boolean containsMultiRelationFetch(Set<?> fetches) { for (Object fetchObj : fetches) { Fetch<?, ?> fetch = (Fetch<?, ?>) fetchObj; Attribute<?, ?> attr = fetch.getAttribute(); if (attr.isAssociation() && attr.isCollection()) return true; if (containsMultiRelationFetch(fetch.getFetches())) return true; } return false; }
private static boolean containsMultiRelationJoin(Set<?> fetches) { for (Object fetchObj : fetches) { Fetch<?, ?> fetch = (Fetch<?, ?>) fetchObj; Attribute<?, ?> attr = fetch.getAttribute(); if (attr.isAssociation() && attr.isCollection()) return true; if (containsMultiRelationFetch(fetch.getFetches())) return true; } return false; }
/** * Copy Fetches * * @param from source Fetch * @param to dest Fetch */ public static void copyFetches(Fetch<?, ?> from, Fetch<?, ?> to) { for (Fetch<?, ?> f : from.getFetches()) { Fetch<?, ?> toFetch = to.fetch(f.getAttribute().getName()); // recursively copy fetches copyFetches(f, toFetch); } } }