HHH-16814 add getRootList()

The method getRoots() returning a Set is really inconvenient
This commit is contained in:
Gavin King 2023-06-27 14:57:29 +02:00
parent 95bcd9460f
commit 3c2d4f9616
4 changed files with 18 additions and 0 deletions

View File

@ -13,6 +13,7 @@ import jakarta.persistence.criteria.Expression;
import jakarta.persistence.criteria.Order;
import jakarta.persistence.criteria.ParameterExpression;
import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root;
import jakarta.persistence.criteria.Selection;
import jakarta.persistence.metamodel.EntityType;
@ -49,6 +50,11 @@ public interface JpaCriteriaQuery<T> extends CriteriaQuery<T>, JpaQueryableCrite
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Accessors
/**
* Return the {@linkplain #getRoots() roots} as a list.
*/
List<Root<?>> getRootList();
@Override
@SuppressWarnings("unchecked")
default List<Order> getOrderList() {

View File

@ -46,6 +46,8 @@ public interface JpaQueryStructure<T> extends JpaQueryPart<T> {
Set<? extends JpaRoot<?>> getRoots();
List<? extends JpaRoot<?>> getRootList();
JpaQueryStructure addRoot(JpaRoot<?> root);

View File

@ -211,6 +211,10 @@ public abstract class AbstractSqmSelectQuery<T>
return (Set) getQuerySpec().getRoots();
}
public List<Root<?>> getRootList() {
return (List) getQuerySpec().getRootList();
}
@Override
public <X> SqmRoot<X> from(Class<X> entityClass) {
return addRoot(

View File

@ -318,6 +318,12 @@ public class SqmQuerySpec<T> extends SqmQueryPart<T>
return new HashSet<>( getFromClause().getRoots() );
}
@Override
public List<SqmRoot<?>> getRootList() {
assert getFromClause() != null;
return getFromClause().getRoots();
}
@Override
public SqmQuerySpec<T> addRoot(JpaRoot<?> root) {
if ( getFromClause() == null ) {