HHH-17355 Add array_to_string to NodeBuilder

This commit is contained in:
Christian Beikov 2023-10-30 19:17:00 +01:00
parent 79e3af5464
commit e4d8181fb8
2 changed files with 198 additions and 60 deletions

View File

@ -791,6 +791,34 @@ public interface NodeBuilder extends HibernateCriteriaBuilder {
*/
<T> SqmExpression<List<Integer>> arrayPositionsList(T[] array, T element);
/**
* Concatenates the non-null array elements with a separator, as specified by the arguments.
*
* @since 6.4
*/
<T> SqmExpression<String> arrayToString(SqmExpression<? extends Object[]> arrayExpression, SqmExpression<String> separatorExpression);
/**
* Concatenates the non-null array elements with a separator, as specified by the arguments.
*
* @since 6.4
*/
<T> SqmExpression<String> arrayToString(SqmExpression<? extends Object[]> arrayExpression, String separator);
/**
* Concatenates the non-null array elements with a separator, as specified by the arguments.
*
* @since 6.4
*/
<T> SqmExpression<String> arrayToString(Object[] array, SqmExpression<String> separatorExpression);
/**
* Concatenates the non-null array elements with a separator, as specified by the arguments.
*
* @since 6.4
*/
<T> SqmExpression<String> arrayToString(Object[] array, String separator);
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Array functions for collection types
@ -1445,6 +1473,34 @@ public interface NodeBuilder extends HibernateCriteriaBuilder {
*/
<T> SqmExpression<List<Integer>> collectionPositionsList(Collection<? super T> collection, T element);
/**
* Concatenates the non-null basic collection elements with a separator, as specified by the arguments.
*
* @since 6.4
*/
<T> SqmExpression<String> collectionToString(SqmExpression<? extends Collection<?>> collectionExpression, SqmExpression<String> separatorExpression);
/**
* Concatenates the non-null basic collection elements with a separator, as specified by the arguments.
*
* @since 6.4
*/
<T> SqmExpression<String> collectionToString(SqmExpression<? extends Collection<?>> collectionExpression, String separator);
/**
* Concatenates the non-null basic collection elements with a separator, as specified by the arguments.
*
* @since 6.4
*/
<T> SqmExpression<String> collectionToString(Collection<?> collection, SqmExpression<String> separatorExpression);
/**
* Concatenates the non-null basic collection elements with a separator, as specified by the arguments.
*
* @since 6.4
*/
<T> SqmExpression<String> collectionToString(Collection<?> collection, String separator);
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Covariant overrides

View File

@ -4551,6 +4551,46 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext,
);
}
@Override
public <T> SqmExpression<String> arrayToString(
SqmExpression<? extends Object[]> arrayExpression,
SqmExpression<String> separatorExpression) {
return getFunctionDescriptor( "array_to_string" ).generateSqmExpression(
asList( arrayExpression, separatorExpression ),
null,
queryEngine
);
}
@Override
public <T> SqmExpression<String> arrayToString(
SqmExpression<? extends Object[]> arrayExpression,
String separator) {
return getFunctionDescriptor( "array_to_string" ).generateSqmExpression(
asList( arrayExpression, value( separator ) ),
null,
queryEngine
);
}
@Override
public <T> SqmExpression<String> arrayToString(Object[] array, SqmExpression<String> separatorExpression) {
return getFunctionDescriptor( "array_to_string" ).generateSqmExpression(
asList( value( array ), separatorExpression ),
null,
queryEngine
);
}
@Override
public <T> SqmExpression<String> arrayToString(Object[] array, String separator) {
return getFunctionDescriptor( "array_to_string" ).generateSqmExpression(
asList( value( array ), value( separator ) ),
null,
queryEngine
);
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Array functions for collection types
@ -4586,6 +4626,90 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext,
);
}
@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
);
}
@Override
public SqmExpression<Integer> collectionLength(SqmExpression<? extends Collection<?>> collectionExpression) {
return getFunctionDescriptor( "array_length" ).generateSqmExpression(
@ -5462,84 +5586,42 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext,
}
@Override
public <T> SqmExpression<int[]> collectionPositions(
SqmExpression<? extends Collection<? super T>> collectionExpression,
SqmExpression<T> elementExpression) {
return getFunctionDescriptor( "array_positions" ).generateSqmExpression(
asList( collectionExpression, elementExpression ),
public <T> SqmExpression<String> collectionToString(
SqmExpression<? extends Collection<?>> collectionExpression,
SqmExpression<String> separatorExpression) {
return getFunctionDescriptor( "array_to_string" ).generateSqmExpression(
asList( collectionExpression, separatorExpression ),
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 ) ),
public <T> SqmExpression<String> collectionToString(
SqmExpression<? extends Collection<?>> collectionExpression,
String separator) {
return getFunctionDescriptor( "array_to_string" ).generateSqmExpression(
asList( collectionExpression, value( separator ) ),
null,
queryEngine
);
}
@Override
public <T> SqmExpression<int[]> collectionPositions(
Collection<? super T> collection,
SqmExpression<T> elementExpression) {
return getFunctionDescriptor( "array_positions" ).generateSqmExpression(
asList( value( collection ), elementExpression ),
public <T> SqmExpression<String> collectionToString(
Collection<?> collection,
SqmExpression<String> separatorExpression) {
return getFunctionDescriptor( "array_to_string" ).generateSqmExpression(
asList( value( collection ), separatorExpression ),
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 ) ),
public <T> SqmExpression<String> collectionToString(Collection<?> collection, String separator) {
return getFunctionDescriptor( "array_to_string" ).generateSqmExpression(
asList( value( collection ), value( separator ) ),
null,
queryEngine
);