HHH-8488 : Replace jdk8-specific code with jdk6-compliant code

This commit is contained in:
Gail Badner 2016-08-10 15:11:40 -07:00
parent 02c86507ba
commit c60287264f
3 changed files with 26 additions and 18 deletions

View File

@ -1102,31 +1102,46 @@ public class CriteriaBuilderImpl implements CriteriaBuilder, Serializable {
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <X, T, V extends T> Join<X, V> treat(Join<X, T> join, Class<V> type) { public <X, T, V extends T> Join<X, V> treat(Join<X, T> join, Class<V> type) {
return treat( join, type, (j, t) -> ((JoinImplementor) j).treatAs( t ) ); final Set<Join<X, ?>> joins = join.getParent().getJoins();
final Join<X, V> treatAs = ( (JoinImplementor) join ).treatAs( type );
joins.add( treatAs );
return treatAs;
} }
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <X, T, E extends T> CollectionJoin<X, E> treat(CollectionJoin<X, T> join, Class<E> type) { public <X, T, E extends T> CollectionJoin<X, E> treat(CollectionJoin<X, T> join, Class<E> type) {
return treat( join, type, (j, t) -> ((CollectionJoinImplementor) j).treatAs( t ) ); final Set<Join<X, ?>> joins = join.getParent().getJoins();
final CollectionJoin<X, E> treatAs = ( (CollectionJoinImplementor) join ).treatAs( type );
joins.add( treatAs );
return treatAs;
} }
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <X, T, E extends T> SetJoin<X, E> treat(SetJoin<X, T> join, Class<E> type) { public <X, T, E extends T> SetJoin<X, E> treat(SetJoin<X, T> join, Class<E> type) {
return treat( join, type, (j, t) -> ((SetJoinImplementor) j).treatAs( t ) ); final Set<Join<X, ?>> joins = join.getParent().getJoins();
final SetJoin<X, E> treatAs = ( (SetJoinImplementor) join ).treatAs( type );
joins.add( treatAs );
return treatAs;
} }
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <X, T, E extends T> ListJoin<X, E> treat(ListJoin<X, T> join, Class<E> type) { public <X, T, E extends T> ListJoin<X, E> treat(ListJoin<X, T> join, Class<E> type) {
return treat( join, type, (j, t) -> ((ListJoinImplementor) join).treatAs( type ) ); final Set<Join<X, ?>> joins = join.getParent().getJoins();
final ListJoin<X, E> treatAs = ( (ListJoinImplementor) join ).treatAs( type );
joins.add( treatAs );
return treatAs;
} }
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <X, K, T, V extends T> MapJoin<X, K, V> treat(MapJoin<X, K, T> join, Class<V> type) { public <X, K, T, V extends T> MapJoin<X, K, V> treat(MapJoin<X, K, T> join, Class<V> type) {
return treat( join, type, (j, t) -> ((MapJoinImplementor) join).treatAs( type ) ); final Set<Join<X, ?>> joins = join.getParent().getJoins();
final MapJoin<X, K, V> treatAs = ( (MapJoinImplementor) join ).treatAs( type );
joins.add( treatAs );
return treatAs;
} }
@Override @Override
@ -1346,14 +1361,4 @@ public class CriteriaBuilderImpl implements CriteriaBuilder, Serializable {
public <E, C extends Collection<E>> Predicate isNotMember(Expression<E> eExpression, Expression<C> cExpression) { public <E, C extends Collection<E>> Predicate isNotMember(Expression<E> eExpression, Expression<C> cExpression) {
return isMember(eExpression, cExpression).not(); return isMember(eExpression, cExpression).not();
} }
private <X, T, V extends T, K extends JoinImplementor> K treat(
Join<X, T> join,
Class<V> type,
BiFunction<Join<X, T>, Class<V>, K> f) {
final Set<Join<X, ?>> joins = join.getParent().getJoins();
final K treatAs = f.apply( join, type );
joins.add(treatAs);
return treatAs;
}
} }

View File

@ -23,7 +23,5 @@ public interface FromImplementor<Z,X> extends PathImplementor<X>, From<Z,X> {
void prepareCorrelationDelegate(FromImplementor<Z,X> parent); void prepareCorrelationDelegate(FromImplementor<Z,X> parent);
FromImplementor<Z, X> getCorrelationParent(); FromImplementor<Z, X> getCorrelationParent();
default boolean shouldBeRendered(){ boolean shouldBeRendered();
return true;
}
} }

View File

@ -96,6 +96,11 @@ public abstract class AbstractFromImpl<Z, X>
return getAlias(); return getAlias();
} }
@Override
public boolean shouldBeRendered() {
return true;
}
@Override @Override
public String render(RenderingContext renderingContext) { public String render(RenderingContext renderingContext) {
return renderProjection( renderingContext ); return renderProjection( renderingContext );