HHH-17355 Add array_positions and array_positions_list to NodeBuilder

This commit is contained in:
Christian Beikov 2023-10-30 18:18:43 +01:00
parent c3e1815486
commit d558df9b64
2 changed files with 272 additions and 0 deletions

View File

@ -735,6 +735,62 @@ public interface NodeBuilder extends HibernateCriteriaBuilder {
*/
<T> SqmExpression<T[]> arrayFill(T element, Integer elementCount);
/**
* Determines all 1-based positions of an element in an array.
*
* @since 6.4
*/
<T> SqmExpression<int[]> arrayPositions(SqmExpression<T[]> arrayExpression, SqmExpression<T> elementExpression);
/**
* Determines all 1-based positions of an element in an array.
*
* @since 6.4
*/
<T> SqmExpression<int[]> arrayPositions(SqmExpression<T[]> arrayExpression, T element);
/**
* Determines all 1-based positions of an element in an array.
*
* @since 6.4
*/
<T> SqmExpression<int[]> arrayPositions(T[] array, SqmExpression<T> elementExpression);
/**
* Determines all 1-based positions of an element in an array.
*
* @since 6.4
*/
<T> SqmExpression<int[]> arrayPositions(T[] array, T element);
/**
* Determines all 1-based positions of an element in an array.
*
* @since 6.4
*/
<T> SqmExpression<List<Integer>> arrayPositionsList(SqmExpression<T[]> arrayExpression, SqmExpression<T> elementExpression);
/**
* Determines all 1-based positions of an element in an array.
*
* @since 6.4
*/
<T> SqmExpression<List<Integer>> arrayPositionsList(SqmExpression<T[]> arrayExpression, T element);
/**
* Determines all 1-based positions of an element in an array.
*
* @since 6.4
*/
<T> SqmExpression<List<Integer>> arrayPositionsList(T[] array, SqmExpression<T> elementExpression);
/**
* Determines all 1-based positions of an element in an array.
*
* @since 6.4
*/
<T> SqmExpression<List<Integer>> arrayPositionsList(T[] array, T element);
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Array functions for collection types
@ -1333,6 +1389,62 @@ public interface NodeBuilder extends HibernateCriteriaBuilder {
*/
<T> SqmExpression<Collection<T>> collectionFill(T element, Integer elementCount);
/**
* Determines all 1-based positions of an element in a basic collection.
*
* @since 6.4
*/
<T> SqmExpression<int[]> collectionPositions(SqmExpression<? extends Collection<? super T>> collectionExpression, SqmExpression<T> elementExpression);
/**
* Determines all 1-based positions of an element in a basic collection.
*
* @since 6.4
*/
<T> SqmExpression<int[]> collectionPositions(SqmExpression<? extends Collection<? super T>> collectionExpression, T element);
/**
* Determines all 1-based positions of an element in a basic collection.
*
* @since 6.4
*/
<T> SqmExpression<int[]> collectionPositions(Collection<? super T> collection, SqmExpression<T> elementExpression);
/**
* Determines all 1-based positions of an element in a basic collection.
*
* @since 6.4
*/
<T> SqmExpression<int[]> collectionPositions(Collection<? super T> collection, T element);
/**
* Determines all 1-based positions of an element in a basic collection.
*
* @since 6.4
*/
<T> SqmExpression<List<Integer>> collectionPositionsList(SqmExpression<? extends Collection<? super T>> collectionExpression, SqmExpression<T> elementExpression);
/**
* Determines all 1-based positions of an element in a basic collection.
*
* @since 6.4
*/
<T> SqmExpression<List<Integer>> collectionPositionsList(SqmExpression<? extends Collection<? super T>> collectionExpression, T element);
/**
* Determines all 1-based positions of an element in a basic collection.
*
* @since 6.4
*/
<T> SqmExpression<List<Integer>> collectionPositionsList(Collection<? super T> collection, SqmExpression<T> elementExpression);
/**
* Determines all 1-based positions of an element in a basic collection.
*
* @since 6.4
*/
<T> SqmExpression<List<Integer>> collectionPositionsList(Collection<? super T> collection, T element);
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Covariant overrides

View File

@ -3685,6 +3685,82 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext,
);
}
@Override
public <T> SqmExpression<int[]> arrayPositions(
SqmExpression<T[]> arrayExpression,
SqmExpression<T> elementExpression) {
return getFunctionDescriptor( "array_positions" ).generateSqmExpression(
asList( arrayExpression, elementExpression ),
null,
queryEngine
);
}
@Override
public <T> SqmExpression<int[]> arrayPositions(SqmExpression<T[]> arrayExpression, T element) {
return getFunctionDescriptor( "array_positions" ).generateSqmExpression(
asList( arrayExpression, value( element ) ),
null,
queryEngine
);
}
@Override
public <T> SqmExpression<int[]> arrayPositions(T[] array, SqmExpression<T> elementExpression) {
return getFunctionDescriptor( "array_positions" ).generateSqmExpression(
asList( value( array ), elementExpression ),
null,
queryEngine
);
}
@Override
public <T> SqmExpression<int[]> arrayPositions(T[] array, T element) {
return getFunctionDescriptor( "array_positions" ).generateSqmExpression(
asList( value( array ), value( element ) ),
null,
queryEngine
);
}
@Override
public <T> SqmExpression<List<Integer>> arrayPositionsList(
SqmExpression<T[]> arrayExpression,
SqmExpression<T> elementExpression) {
return getFunctionDescriptor( "array_positions_list" ).generateSqmExpression(
asList( arrayExpression, elementExpression ),
null,
queryEngine
);
}
@Override
public <T> SqmExpression<List<Integer>> arrayPositionsList(SqmExpression<T[]> arrayExpression, T element) {
return getFunctionDescriptor( "array_positions_list" ).generateSqmExpression(
asList( arrayExpression, value( element ) ),
null,
queryEngine
);
}
@Override
public <T> SqmExpression<List<Integer>> arrayPositionsList(T[] array, SqmExpression<T> elementExpression) {
return getFunctionDescriptor( "array_positions_list" ).generateSqmExpression(
asList( value( array ), elementExpression ),
null,
queryEngine
);
}
@Override
public <T> SqmExpression<List<Integer>> arrayPositionsList(T[] array, T element) {
return getFunctionDescriptor( "array_positions_list" ).generateSqmExpression(
asList( value( array ), value( element ) ),
null,
queryEngine
);
}
@Override
public <T> SqmExpression<Integer> arrayLength(SqmExpression<T[]> arrayExpression) {
return getFunctionDescriptor( "array_length" ).generateSqmExpression(
@ -5384,4 +5460,88 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext,
queryEngine
);
}
@Override
public <T> SqmExpression<int[]> collectionPositions(
SqmExpression<? extends Collection<? super T>> collectionExpression,
SqmExpression<T> elementExpression) {
return getFunctionDescriptor( "array_positions" ).generateSqmExpression(
asList( collectionExpression, elementExpression ),
null,
queryEngine
);
}
@Override
public <T> SqmExpression<int[]> collectionPositions(
SqmExpression<? extends Collection<? super T>> collectionExpression,
T element) {
return getFunctionDescriptor( "array_positions" ).generateSqmExpression(
asList( collectionExpression, value( element ) ),
null,
queryEngine
);
}
@Override
public <T> SqmExpression<int[]> collectionPositions(
Collection<? super T> collection,
SqmExpression<T> elementExpression) {
return getFunctionDescriptor( "array_positions" ).generateSqmExpression(
asList( value( collection ), elementExpression ),
null,
queryEngine
);
}
@Override
public <T> SqmExpression<int[]> collectionPositions(Collection<? super T> collection, T element) {
return getFunctionDescriptor( "array_positions" ).generateSqmExpression(
asList( value( collection ), value( element ) ),
null,
queryEngine
);
}
@Override
public <T> SqmExpression<List<Integer>> collectionPositionsList(
SqmExpression<? extends Collection<? super T>> collectionExpression,
SqmExpression<T> elementExpression) {
return getFunctionDescriptor( "array_positions_list" ).generateSqmExpression(
asList( collectionExpression, elementExpression ),
null,
queryEngine
);
}
@Override
public <T> SqmExpression<List<Integer>> collectionPositionsList(
SqmExpression<? extends Collection<? super T>> collectionExpression,
T element) {
return getFunctionDescriptor( "array_positions_list" ).generateSqmExpression(
asList( collectionExpression, value( element ) ),
null,
queryEngine
);
}
@Override
public <T> SqmExpression<List<Integer>> collectionPositionsList(
Collection<? super T> collection,
SqmExpression<T> elementExpression) {
return getFunctionDescriptor( "array_positions_list" ).generateSqmExpression(
asList( value( collection ), elementExpression ),
null,
queryEngine
);
}
@Override
public <T> SqmExpression<List<Integer>> collectionPositionsList(Collection<? super T> collection, T element) {
return getFunctionDescriptor( "array_positions_list" ).generateSqmExpression(
asList( value( collection ), value( element ) ),
null,
queryEngine
);
}
}