Skip to content

Commit

Permalink
HHH-17355 Add array_to_string to NodeBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
beikov committed Nov 6, 2023
1 parent 79e3af5 commit e4d8181
Show file tree
Hide file tree
Showing 2 changed files with 198 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,34 @@ <T> JpaExpression<T[]> arrayAgg(
*/
<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

Expand Down Expand Up @@ -1445,6 +1473,34 @@ <T> JpaExpression<T[]> arrayAgg(
*/
<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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4551,6 +4551,46 @@ public <T> SqmExpression<T[]> arrayFill(T element, Integer elementCount) {
);
}

@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

Expand Down Expand Up @@ -4586,6 +4626,90 @@ public <E> SqmExpression<Integer> collectionPosition(
);
}

@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(
Expand Down Expand Up @@ -5462,84 +5586,42 @@ public <T> SqmExpression<Collection<T>> collectionFill(T element, Integer elemen
}

@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 ) ),
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 ) ),
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<List<Integer>> collectionPositionsList(
Collection<? super T> collection,
SqmExpression<T> elementExpression) {
return getFunctionDescriptor( "array_positions_list" ).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<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
);
Expand Down

0 comments on commit e4d8181

Please sign in to comment.