HHH-17377 - Migrate to JPA 3.2

https://hibernate.atlassian.net/browse/HHH-17377

Test compilation success!!  95 test failures next
This commit is contained in:
Steve Ebersole 2023-11-02 00:17:24 -05:00
parent c3c3c16a65
commit 9dabfb7abb
2 changed files with 88 additions and 36 deletions

View File

@ -187,30 +187,8 @@ public interface HibernateCriteriaBuilder extends CriteriaBuilder {
@Override @Override
<T> JpaCriteriaQuery<T> union(CriteriaQuery<? extends T> left, CriteriaQuery<? extends T> right); <T> JpaCriteriaQuery<T> union(CriteriaQuery<? extends T> left, CriteriaQuery<? extends T> right);
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override @Override
default <T> JpaCriteriaQuery<T> unionAll(CriteriaQuery<? extends T> left, CriteriaQuery<? extends T> right) { <T> JpaCriteriaQuery<T> unionAll(CriteriaQuery<? extends T> left, CriteriaQuery<? extends T> right);
// for now at least...
assert left instanceof SqmSelectStatement;
final SqmSelectStatement<? extends T> leftSqm = (SqmSelectStatement<? extends T>) left;
final SqmSelectStatement<? extends T> rightSqm = (SqmSelectStatement<? extends T>) right;
// SqmQueryGroup is the UNION ALL between the two
final SqmQueryGroup sqmQueryGroup = new SqmQueryGroup(
leftSqm.nodeBuilder(),
SetOperator.UNION_ALL,
List.of( leftSqm.getQueryPart(), rightSqm.getQueryPart() )
);
final SqmSelectStatement sqmSelectStatement = new SqmSelectStatement<>(
leftSqm.getResultType(),
SqmQuerySource.CRITERIA,
leftSqm.nodeBuilder()
);
sqmSelectStatement.setQueryPart( sqmQueryGroup );
return sqmSelectStatement;
}
default <T> JpaSubQuery<T> union(Subquery<? extends T> query1, Subquery<?>... queries) { default <T> JpaSubQuery<T> union(Subquery<? extends T> query1, Subquery<?>... queries) {
return union( false, query1, queries ); return union( false, query1, queries );

View File

@ -549,43 +549,117 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext,
@Override @Override
public <T> JpaCriteriaQuery<T> union(CriteriaQuery<? extends T> left, CriteriaQuery<? extends T> right) { public <T> JpaCriteriaQuery<T> union(CriteriaQuery<? extends T> left, CriteriaQuery<? extends T> right) {
// todo (jpa 3.2) : implement return createUnionSet( SetOperator.UNION, left, right );
throw new UnsupportedOperationException( "Not yet implemented" );
} }
@Override @Override
public <T> JpaCriteriaQuery<T> unionAll(CriteriaQuery<? extends T> left, CriteriaQuery<? extends T> right) { public <T> JpaCriteriaQuery<T> unionAll(CriteriaQuery<? extends T> left, CriteriaQuery<? extends T> right) {
// todo (jpa 3.2) : implement return createUnionSet( SetOperator.UNION_ALL, left, right );
throw new UnsupportedOperationException( "Not yet implemented" ); }
@SuppressWarnings({ "rawtypes", "unchecked" })
private static <T> JpaCriteriaQuery<T> createUnionSet(
SetOperator operator,
CriteriaQuery<? extends T> left,
CriteriaQuery<? extends T> right) {
assert operator == SetOperator.UNION || operator == SetOperator.UNION_ALL;
assert left instanceof SqmSelectStatement;
assert right instanceof SqmSelectStatement;
final SqmSelectStatement<? extends T> leftSqm = (SqmSelectStatement<? extends T>) left;
final SqmSelectStatement<? extends T> rightSqm = (SqmSelectStatement<? extends T>) right;
// SqmQueryGroup is the UNION ALL between the two
final SqmQueryGroup sqmQueryGroup = new SqmQueryGroup(
leftSqm.nodeBuilder(),
operator,
List.of( leftSqm.getQueryPart(), rightSqm.getQueryPart() )
);
final SqmSelectStatement sqmSelectStatement = new SqmSelectStatement<>(
leftSqm.getResultType(),
SqmQuerySource.CRITERIA,
leftSqm.nodeBuilder()
);
sqmSelectStatement.setQueryPart( sqmQueryGroup );
return sqmSelectStatement;
} }
@Override @Override
public <T> JpaCriteriaQuery<T> intersect(CriteriaQuery<? super T> left, CriteriaQuery<? super T> right) { public <T> JpaCriteriaQuery<T> intersect(CriteriaQuery<? super T> left, CriteriaQuery<? super T> right) {
// todo (jpa 3.2) : implement return createIntersectSet( SetOperator.INTERSECT, left, right );
throw new UnsupportedOperationException( "Not yet implemented" );
} }
@Override @Override
public <T> JpaCriteriaQuery<T> intersectAll(CriteriaQuery<? super T> left, CriteriaQuery<? super T> right) { public <T> JpaCriteriaQuery<T> intersectAll(CriteriaQuery<? super T> left, CriteriaQuery<? super T> right) {
// todo (jpa 3.2) : implement return createIntersectSet( SetOperator.INTERSECT_ALL, left, right );
throw new UnsupportedOperationException( "Not yet implemented" ); }
@SuppressWarnings({ "rawtypes", "unchecked" })
private static <T> JpaCriteriaQuery<T> createIntersectSet(
SetOperator operator,
CriteriaQuery<? super T> left,
CriteriaQuery<? super T> right) {
assert operator == SetOperator.INTERSECT || operator == SetOperator.INTERSECT_ALL;
assert left instanceof SqmSelectStatement;
assert right instanceof SqmSelectStatement;
final SqmSelectStatement<? extends T> leftSqm = (SqmSelectStatement<? extends T>) left;
final SqmSelectStatement<? extends T> rightSqm = (SqmSelectStatement<? extends T>) right;
// SqmQueryGroup is the UNION ALL between the two
final SqmQueryGroup sqmQueryGroup = new SqmQueryGroup(
leftSqm.nodeBuilder(),
operator,
List.of( leftSqm.getQueryPart(), rightSqm.getQueryPart() )
);
final SqmSelectStatement sqmSelectStatement = new SqmSelectStatement<>(
leftSqm.getResultType(),
SqmQuerySource.CRITERIA,
leftSqm.nodeBuilder()
);
sqmSelectStatement.setQueryPart( sqmQueryGroup );
return sqmSelectStatement;
} }
@Override @Override
public <T> JpaCriteriaQuery<T> except(CriteriaQuery<T> left, CriteriaQuery<?> right) { public <T> JpaCriteriaQuery<T> except(CriteriaQuery<T> left, CriteriaQuery<?> right) {
// todo (jpa 3.2) : implement return createExceptSet( SetOperator.EXCEPT, left, right );
throw new UnsupportedOperationException( "Not yet implemented" );
} }
@Override @Override
public <T> JpaCriteriaQuery<T> exceptAll(CriteriaQuery<T> left, CriteriaQuery<?> right) { public <T> JpaCriteriaQuery<T> exceptAll(CriteriaQuery<T> left, CriteriaQuery<?> right) {
// todo (jpa 3.2) : implement return createExceptSet( SetOperator.EXCEPT_ALL, left, right );
throw new UnsupportedOperationException( "Not yet implemented" ); }
@SuppressWarnings({ "rawtypes", "unchecked" })
private static <T> JpaCriteriaQuery<T> createExceptSet(
SetOperator operator,
CriteriaQuery<T> left,
CriteriaQuery<?> right) {
assert operator == SetOperator.EXCEPT || operator == SetOperator.EXCEPT_ALL;
assert left instanceof SqmSelectStatement;
assert right instanceof SqmSelectStatement;
final SqmSelectStatement<? extends T> leftSqm = (SqmSelectStatement<? extends T>) left;
final SqmSelectStatement<? extends T> rightSqm = (SqmSelectStatement<? extends T>) right;
// SqmQueryGroup is the UNION ALL between the two
final SqmQueryGroup sqmQueryGroup = new SqmQueryGroup(
leftSqm.nodeBuilder(),
operator,
List.of( leftSqm.getQueryPart(), rightSqm.getQueryPart() )
);
final SqmSelectStatement sqmSelectStatement = new SqmSelectStatement<>(
leftSqm.getResultType(),
SqmQuerySource.CRITERIA,
leftSqm.nodeBuilder()
);
sqmSelectStatement.setQueryPart( sqmQueryGroup );
return sqmSelectStatement;
} }
@Override @Override
public <X, T, V extends T> SqmSingularJoin<X, V> treat(Join<X, T> join, Class<V> type) { public <X, T, V extends T> SqmSingularJoin<X, V> treat(Join<X, T> join, Class<V> type) {
//noinspection unchecked
return (SqmTreatedSingularJoin<X,T,V>) ( (SqmSingularJoin<X, T>) join ).treatAs( type ); return (SqmTreatedSingularJoin<X,T,V>) ( (SqmSingularJoin<X, T>) join ).treatAs( type );
} }