HHH-17355 Test array functions with NodeBuilder
This commit is contained in:
parent
e4d8181fb8
commit
d7bdb5c009
|
@ -1118,6 +1118,7 @@ The following functions deal with SQL array types, which are not supported on ev
|
|||
| Function | Purpose
|
||||
|
||||
| `array()` | Creates an array based on the passed arguments
|
||||
| `array_list()` | Like `array`, but returns the result as `List<?>`
|
||||
| `array_agg()` | Aggregates row values into an array
|
||||
| `array_position()` | Determines the position of an element in an array
|
||||
| `array_positions()` | Determines all positions of an element in an array
|
||||
|
@ -1138,12 +1139,15 @@ The following functions deal with SQL array types, which are not supported on ev
|
|||
| `array_replace()` | Creates array copy replacing a given element with another
|
||||
| `array_trim()` | Creates array copy trimming the last _N_ elements
|
||||
| `array_fill()` | Creates array filled with the same element _N_ times
|
||||
| `array_fill_list()` | Like `array_fill`, but returns the result as `List<?>`
|
||||
| `array_to_string()` | String representation of non-null array elements
|
||||
|===
|
||||
|
||||
===== `array()`
|
||||
[[hql-array-constructor-functions]]
|
||||
===== `array()` and `array_list()`
|
||||
|
||||
Creates an array based on the passed arguments, and infers the array type from the context if possible.
|
||||
To retrieve the result as `List<?>`, use the `array_list()` function.
|
||||
|
||||
[[hql-array-constructor-example]]
|
||||
====
|
||||
|
@ -1153,6 +1157,7 @@ include::{array-example-dir-hql}/ArrayConstructorTest.java[tags=hql-array-exampl
|
|||
----
|
||||
====
|
||||
|
||||
[[hql-array-aggregate-functions]]
|
||||
===== `array_agg()`
|
||||
|
||||
An <<hql-aggregate-functions-orderedset,ordered set aggregate function>> that aggregates values to an array.
|
||||
|
@ -1404,6 +1409,7 @@ include::{array-example-dir-hql}/ArrayReplaceTest.java[tags=hql-array-replace-ex
|
|||
----
|
||||
====
|
||||
|
||||
[[hql-array-trim-functions]]
|
||||
===== `array_trim()`
|
||||
|
||||
Returns an array copy without the last _N_ elements, specified by the second argument.
|
||||
|
@ -1417,10 +1423,12 @@ include::{array-example-dir-hql}/ArrayTrimTest.java[tags=hql-array-trim-example]
|
|||
----
|
||||
====
|
||||
|
||||
===== `array_fill()`
|
||||
[[hql-array-fill-functions]]
|
||||
===== `array_fill()` and `array_fill_list()`
|
||||
|
||||
Creates an array filled with the same element _N_ times as specified by the arguments.
|
||||
It is an error to supply an array length smaller than 0.
|
||||
To retrieve the result as `List<?>`, use the `array_fill_list()` function.
|
||||
|
||||
[[hql-array-fill-example]]
|
||||
====
|
||||
|
@ -1430,6 +1438,7 @@ include::{array-example-dir-hql}/ArrayFillTest.java[tags=hql-array-fill-example]
|
|||
----
|
||||
====
|
||||
|
||||
[[hql-array-to-string-functions]]
|
||||
===== `array_to_string()`
|
||||
|
||||
Concatenates the non-null array elements with a separator, as specified by the arguments.
|
||||
|
|
|
@ -6,12 +6,9 @@
|
|||
*/
|
||||
package org.hibernate.dialect.function;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Date;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.annotations.common.reflection.java.generics.ParameterizedTypeImpl;
|
||||
import org.hibernate.boot.model.FunctionContributions;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
|
||||
|
@ -2604,35 +2601,40 @@ public class CommonFunctionFactory {
|
|||
* H2, HSQL array() constructor function
|
||||
*/
|
||||
public void array() {
|
||||
functionRegistry.register( "array", new ArrayConstructorFunction( true ) );
|
||||
functionRegistry.register( "array", new ArrayConstructorFunction( false, true ) );
|
||||
functionRegistry.register( "array_list", new ArrayConstructorFunction( true, true ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* H2, HSQL array() constructor function
|
||||
*/
|
||||
public void array_hsql() {
|
||||
functionRegistry.register( "array", new HSQLArrayConstructorFunction() );
|
||||
functionRegistry.register( "array", new HSQLArrayConstructorFunction( false ) );
|
||||
functionRegistry.register( "array_list", new HSQLArrayConstructorFunction( true ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* CockroachDB and PostgreSQL array() constructor function
|
||||
*/
|
||||
public void array_postgresql() {
|
||||
functionRegistry.register( "array", new PostgreSQLArrayConstructorFunction() );
|
||||
functionRegistry.register( "array", new PostgreSQLArrayConstructorFunction( false ) );
|
||||
functionRegistry.register( "array_list", new PostgreSQLArrayConstructorFunction( true ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Google Spanner array() constructor function
|
||||
*/
|
||||
public void array_spanner() {
|
||||
functionRegistry.register( "array", new ArrayConstructorFunction( false ) );
|
||||
functionRegistry.register( "array", new ArrayConstructorFunction( false, false ) );
|
||||
functionRegistry.register( "array_list", new ArrayConstructorFunction( true, false ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Oracle array() constructor function
|
||||
*/
|
||||
public void array_oracle() {
|
||||
functionRegistry.register( "array", new OracleArrayConstructorFunction() );
|
||||
functionRegistry.register( "array", new OracleArrayConstructorFunction( false ) );
|
||||
functionRegistry.register( "array_list", new OracleArrayConstructorFunction( true ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3175,28 +3177,32 @@ public class CommonFunctionFactory {
|
|||
* H2 array_fill() function
|
||||
*/
|
||||
public void arrayFill_h2() {
|
||||
functionRegistry.register( "array_fill", new H2ArrayFillFunction() );
|
||||
functionRegistry.register( "array_fill", new H2ArrayFillFunction( false ) );
|
||||
functionRegistry.register( "array_fill_list", new H2ArrayFillFunction( true ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* HSQLDB array_fill() function
|
||||
*/
|
||||
public void arrayFill_hsql() {
|
||||
functionRegistry.register( "array_fill", new HSQLArrayFillFunction() );
|
||||
functionRegistry.register( "array_fill", new HSQLArrayFillFunction( false ) );
|
||||
functionRegistry.register( "array_fill_list", new HSQLArrayFillFunction( true ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* PostgreSQL array_fill() function
|
||||
*/
|
||||
public void arrayFill_postgresql() {
|
||||
functionRegistry.register( "array_fill", new PostgreSQLArrayFillFunction() );
|
||||
functionRegistry.register( "array_fill", new PostgreSQLArrayFillFunction( false ) );
|
||||
functionRegistry.register( "array_fill_list", new PostgreSQLArrayFillFunction( true ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Oracle array_fill() function
|
||||
*/
|
||||
public void arrayFill_oracle() {
|
||||
functionRegistry.register( "array_fill", new OracleArrayFillFunction() );
|
||||
functionRegistry.register( "array_fill", new OracleArrayFillFunction( false ) );
|
||||
functionRegistry.register( "array_fill_list", new OracleArrayFillFunction( true ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,11 +21,13 @@ import org.hibernate.type.BasicPluralType;
|
|||
*/
|
||||
public abstract class AbstractArrayFillFunction extends AbstractSqmSelfRenderingFunctionDescriptor {
|
||||
|
||||
public AbstractArrayFillFunction() {
|
||||
public AbstractArrayFillFunction(boolean list) {
|
||||
super(
|
||||
"array_fill",
|
||||
"array_fill" + ( list ? "_list" : "" ),
|
||||
new ArgumentTypesValidator( null, FunctionParameterType.NO_UNTYPED, FunctionParameterType.INTEGER ),
|
||||
ArrayViaElementArgumentReturnTypeResolver.DEFAULT_INSTANCE,
|
||||
list
|
||||
? ArrayViaElementArgumentReturnTypeResolver.VARARGS_LIST_INSTANCE
|
||||
: ArrayViaElementArgumentReturnTypeResolver.VARARGS_INSTANCE,
|
||||
ArrayFillArgumentsValidator.INSTANCE
|
||||
);
|
||||
}
|
||||
|
|
|
@ -29,11 +29,13 @@ public class ArrayConstructorFunction extends AbstractSqmSelfRenderingFunctionDe
|
|||
|
||||
private final boolean withKeyword;
|
||||
|
||||
public ArrayConstructorFunction(boolean withKeyword) {
|
||||
public ArrayConstructorFunction(boolean list, boolean withKeyword) {
|
||||
super(
|
||||
"array",
|
||||
"array" + ( list ? "_list" : "" ),
|
||||
ArrayConstructorArgumentsValidator.INSTANCE,
|
||||
ArrayViaElementArgumentReturnTypeResolver.VARARGS_INSTANCE,
|
||||
list
|
||||
? ArrayViaElementArgumentReturnTypeResolver.VARARGS_LIST_INSTANCE
|
||||
: ArrayViaElementArgumentReturnTypeResolver.VARARGS_INSTANCE,
|
||||
StandardFunctionArgumentTypeResolvers.NULL
|
||||
);
|
||||
this.withKeyword = withKeyword;
|
||||
|
|
|
@ -24,12 +24,17 @@ import org.hibernate.type.spi.TypeConfiguration;
|
|||
*/
|
||||
public class ArrayViaElementArgumentReturnTypeResolver implements FunctionReturnTypeResolver {
|
||||
|
||||
public static final FunctionReturnTypeResolver DEFAULT_INSTANCE = new ArrayViaElementArgumentReturnTypeResolver( 0 );
|
||||
public static final FunctionReturnTypeResolver VARARGS_INSTANCE = new ArrayViaElementArgumentReturnTypeResolver( -1 );
|
||||
public static final FunctionReturnTypeResolver DEFAULT_INSTANCE = new ArrayViaElementArgumentReturnTypeResolver( false, 0 );
|
||||
|
||||
public static final FunctionReturnTypeResolver DEFAULT_LIST_INSTANCE = new ArrayViaElementArgumentReturnTypeResolver( true, 0 );
|
||||
public static final FunctionReturnTypeResolver VARARGS_INSTANCE = new ArrayViaElementArgumentReturnTypeResolver( false, -1 );
|
||||
public static final FunctionReturnTypeResolver VARARGS_LIST_INSTANCE = new ArrayViaElementArgumentReturnTypeResolver( true, -1 );
|
||||
|
||||
private final boolean list;
|
||||
private final int elementIndex;
|
||||
|
||||
private ArrayViaElementArgumentReturnTypeResolver(int elementIndex) {
|
||||
private ArrayViaElementArgumentReturnTypeResolver(boolean list, int elementIndex) {
|
||||
this.list = list;
|
||||
this.elementIndex = elementIndex;
|
||||
}
|
||||
|
||||
|
@ -55,14 +60,18 @@ public class ArrayViaElementArgumentReturnTypeResolver implements FunctionReturn
|
|||
for ( SqmTypedNode<?> argument : arguments ) {
|
||||
final DomainType<?> sqmType = argument.getExpressible().getSqmType();
|
||||
if ( sqmType instanceof ReturnableType<?> ) {
|
||||
return DdlTypeHelper.resolveArrayType( sqmType, typeConfiguration );
|
||||
return list
|
||||
? DdlTypeHelper.resolveListType( sqmType, typeConfiguration )
|
||||
: DdlTypeHelper.resolveArrayType( sqmType, typeConfiguration );
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
final DomainType<?> sqmType = arguments.get( elementIndex ).getExpressible().getSqmType();
|
||||
if ( sqmType instanceof ReturnableType<?> ) {
|
||||
return DdlTypeHelper.resolveArrayType( sqmType, typeConfiguration );
|
||||
return list
|
||||
? DdlTypeHelper.resolveListType( sqmType, typeConfiguration )
|
||||
: DdlTypeHelper.resolveArrayType( sqmType, typeConfiguration );
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
package org.hibernate.dialect.function.array;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.hibernate.metamodel.model.domain.DomainType;
|
||||
import org.hibernate.query.sqm.SqmExpressible;
|
||||
|
@ -46,7 +47,7 @@ public class ArraysOfSameTypeArgumentValidator implements ArgumentsValidator {
|
|||
}
|
||||
arrayType = (BasicPluralType<?, ?>) sqmType;
|
||||
}
|
||||
else if ( !arrayType.equals( sqmType ) ) {
|
||||
else if ( !isCompatible( arrayType, sqmType ) ) {
|
||||
throw new FunctionArgumentException(
|
||||
String.format(
|
||||
"Parameter %d of function '%s()' requires an array type %s, but argument is of type '%s'",
|
||||
|
@ -61,6 +62,11 @@ public class ArraysOfSameTypeArgumentValidator implements ArgumentsValidator {
|
|||
}
|
||||
}
|
||||
|
||||
private static boolean isCompatible(BasicPluralType<?,?> arrayType, DomainType<?> sqmType) {
|
||||
return arrayType == sqmType || sqmType instanceof BasicPluralType<?, ?>
|
||||
&& Objects.equals( arrayType.getElementType(), ( (BasicPluralType<?, ?>) sqmType ).getElementType() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSignature() {
|
||||
return "(ARRAY array0, ARRAY array1[, ARRAY array2, ...])";
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
package org.hibernate.dialect.function.array;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.engine.jdbc.Size;
|
||||
|
@ -16,11 +18,11 @@ import org.hibernate.metamodel.model.domain.DomainType;
|
|||
import org.hibernate.query.ReturnableType;
|
||||
import org.hibernate.sql.ast.SqlAstTranslator;
|
||||
import org.hibernate.sql.ast.spi.AbstractSqlAstTranslator;
|
||||
import org.hibernate.type.BasicPluralType;
|
||||
import org.hibernate.type.BasicType;
|
||||
import org.hibernate.type.descriptor.java.BasicPluralJavaType;
|
||||
import org.hibernate.type.descriptor.sql.DdlType;
|
||||
import org.hibernate.type.descriptor.sql.spi.DdlTypeRegistry;
|
||||
import org.hibernate.type.internal.ParameterizedTypeImpl;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
public class DdlTypeHelper {
|
||||
|
@ -40,6 +42,24 @@ public class DdlTypeHelper {
|
|||
);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static BasicType<?> resolveListType(DomainType<?> elementType, TypeConfiguration typeConfiguration) {
|
||||
@SuppressWarnings("unchecked") final BasicPluralJavaType<Object> arrayJavaType = (BasicPluralJavaType<Object>) typeConfiguration.getJavaTypeRegistry()
|
||||
.getDescriptor( List.class )
|
||||
.createJavaType(
|
||||
new ParameterizedTypeImpl( List.class, new Type[]{ elementType.getBindableJavaType() }, null ),
|
||||
typeConfiguration
|
||||
);
|
||||
final Dialect dialect = typeConfiguration.getCurrentBaseSqlTypeIndicators().getDialect();
|
||||
return arrayJavaType.resolveType(
|
||||
typeConfiguration,
|
||||
dialect,
|
||||
(BasicType<Object>) elementType,
|
||||
null,
|
||||
typeConfiguration.getCurrentBaseSqlTypeIndicators()
|
||||
);
|
||||
}
|
||||
|
||||
public static String getTypeName(BasicType<?> type, SqlAstTranslator<?> walker) {
|
||||
return getTypeName( (JdbcMappingContainer) type, walker );
|
||||
}
|
||||
|
|
|
@ -18,6 +18,10 @@ import org.hibernate.sql.ast.tree.SqlAstNode;
|
|||
*/
|
||||
public class H2ArrayFillFunction extends AbstractArrayFillFunction {
|
||||
|
||||
public H2ArrayFillFunction(boolean list) {
|
||||
super( list );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(
|
||||
SqlAppender sqlAppender,
|
||||
|
|
|
@ -8,11 +8,8 @@ package org.hibernate.dialect.function.array;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.metamodel.mapping.JdbcMappingContainer;
|
||||
import org.hibernate.metamodel.mapping.SqlTypedMapping;
|
||||
import org.hibernate.query.ReturnableType;
|
||||
import org.hibernate.sql.ast.SqlAstTranslator;
|
||||
import org.hibernate.sql.ast.spi.AbstractSqlAstTranslator;
|
||||
import org.hibernate.sql.ast.spi.SqlAppender;
|
||||
import org.hibernate.sql.ast.tree.SqlAstNode;
|
||||
import org.hibernate.sql.ast.tree.expression.Expression;
|
||||
|
@ -20,8 +17,8 @@ import org.hibernate.type.BottomType;
|
|||
|
||||
public class HSQLArrayConstructorFunction extends ArrayConstructorFunction {
|
||||
|
||||
public HSQLArrayConstructorFunction() {
|
||||
super( true );
|
||||
public HSQLArrayConstructorFunction(boolean list) {
|
||||
super( list, true );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,6 +19,10 @@ import org.hibernate.sql.ast.tree.SqlAstNode;
|
|||
*/
|
||||
public class HSQLArrayFillFunction extends AbstractArrayFillFunction {
|
||||
|
||||
public HSQLArrayFillFunction(boolean list) {
|
||||
super( list );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(
|
||||
SqlAppender sqlAppender,
|
||||
|
|
|
@ -18,8 +18,8 @@ import org.hibernate.type.BasicPluralType;
|
|||
|
||||
public class OracleArrayConstructorFunction extends ArrayConstructorFunction {
|
||||
|
||||
public OracleArrayConstructorFunction() {
|
||||
super( false );
|
||||
public OracleArrayConstructorFunction(boolean list) {
|
||||
super( list, false );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,6 +19,10 @@ import org.hibernate.sql.ast.tree.expression.Expression;
|
|||
*/
|
||||
public class OracleArrayFillFunction extends AbstractArrayFillFunction {
|
||||
|
||||
public OracleArrayFillFunction(boolean list) {
|
||||
super( list );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(
|
||||
SqlAppender sqlAppender,
|
||||
|
|
|
@ -23,8 +23,8 @@ import org.hibernate.type.BasicType;
|
|||
*/
|
||||
public class PostgreSQLArrayConstructorFunction extends ArrayConstructorFunction {
|
||||
|
||||
public PostgreSQLArrayConstructorFunction() {
|
||||
super( true );
|
||||
public PostgreSQLArrayConstructorFunction(boolean list) {
|
||||
super( list, true );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,6 +20,10 @@ import org.hibernate.sql.ast.tree.expression.Literal;
|
|||
*/
|
||||
public class PostgreSQLArrayFillFunction extends AbstractArrayFillFunction {
|
||||
|
||||
public PostgreSQLArrayFillFunction(boolean list) {
|
||||
super( list );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(
|
||||
SqlAppender sqlAppender,
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -57,6 +57,7 @@ import org.hibernate.query.criteria.JpaWindow;
|
|||
import org.hibernate.query.criteria.JpaWindowFrame;
|
||||
import org.hibernate.query.NullPrecedence;
|
||||
import org.hibernate.query.sqm.TemporalUnit;
|
||||
import org.hibernate.query.sqm.tree.expression.SqmExpression;
|
||||
|
||||
import jakarta.persistence.Tuple;
|
||||
import jakarta.persistence.criteria.CollectionJoin;
|
||||
|
@ -2126,4 +2127,891 @@ public class HibernateCriteriaBuilderDelegate implements HibernateCriteriaBuilde
|
|||
public JpaExpression<Duration> duration(long magnitude, TemporalUnit unit) {
|
||||
return criteriaBuilder.duration( magnitude, unit );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T[]> arrayAgg(JpaOrder order, Expression<? extends T> argument) {
|
||||
return criteriaBuilder.arrayAgg( order, argument );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T[]> arrayAgg(JpaOrder order, JpaPredicate filter, Expression<? extends T> argument) {
|
||||
return criteriaBuilder.arrayAgg( order, filter, argument );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T[]> arrayAgg(JpaOrder order, JpaWindow window, Expression<? extends T> argument) {
|
||||
return criteriaBuilder.arrayAgg( order, window, argument );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T[]> arrayAgg(
|
||||
JpaOrder order,
|
||||
JpaPredicate filter,
|
||||
JpaWindow window,
|
||||
Expression<? extends T> argument) {
|
||||
return criteriaBuilder.arrayAgg( order, filter, window, argument );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T[]> arrayLiteral(T... elements) {
|
||||
return criteriaBuilder.arrayLiteral( elements );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<Integer> arrayLength(Expression<T[]> arrayExpression) {
|
||||
return criteriaBuilder.arrayLength( arrayExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<Integer> arrayPosition(Expression<T[]> arrayExpression, T element) {
|
||||
return criteriaBuilder.arrayPosition( arrayExpression, element );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<Integer> arrayPosition(Expression<T[]> arrayExpression, Expression<T> elementExpression) {
|
||||
return criteriaBuilder.arrayPosition( arrayExpression, elementExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<int[]> arrayPositions(Expression<T[]> arrayExpression, Expression<T> elementExpression) {
|
||||
return criteriaBuilder.arrayPositions( arrayExpression, elementExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<int[]> arrayPositions(Expression<T[]> arrayExpression, T element) {
|
||||
return criteriaBuilder.arrayPositions( arrayExpression, element );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<List<Integer>> arrayPositionsList(
|
||||
Expression<T[]> arrayExpression,
|
||||
Expression<T> elementExpression) {
|
||||
return criteriaBuilder.arrayPositionsList( arrayExpression, elementExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<List<Integer>> arrayPositionsList(Expression<T[]> arrayExpression, T element) {
|
||||
return criteriaBuilder.arrayPositionsList( arrayExpression, element );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T[]> arrayConcat(Expression<T[]> arrayExpression1, Expression<T[]> arrayExpression2) {
|
||||
return criteriaBuilder.arrayConcat( arrayExpression1, arrayExpression2 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T[]> arrayConcat(Expression<T[]> arrayExpression1, T[] array2) {
|
||||
return criteriaBuilder.arrayConcat( arrayExpression1, array2 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T[]> arrayConcat(T[] array1, Expression<T[]> arrayExpression2) {
|
||||
return criteriaBuilder.arrayConcat( array1, arrayExpression2 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T[]> arrayAppend(Expression<T[]> arrayExpression, Expression<T> elementExpression) {
|
||||
return criteriaBuilder.arrayAppend( arrayExpression, elementExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T[]> arrayAppend(Expression<T[]> arrayExpression, T element) {
|
||||
return criteriaBuilder.arrayAppend( arrayExpression, element );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T[]> arrayPrepend(Expression<T> elementExpression, Expression<T[]> arrayExpression) {
|
||||
return criteriaBuilder.arrayPrepend( elementExpression, arrayExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T[]> arrayPrepend(T element, Expression<T[]> arrayExpression) {
|
||||
return criteriaBuilder.arrayPrepend( element, arrayExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T> arrayGet(Expression<T[]> arrayExpression, Expression<Integer> indexExpression) {
|
||||
return criteriaBuilder.arrayGet( arrayExpression, indexExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T> arrayGet(Expression<T[]> arrayExpression, Integer index) {
|
||||
return criteriaBuilder.arrayGet( arrayExpression, index );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T[]> arraySet(
|
||||
Expression<T[]> arrayExpression,
|
||||
Expression<Integer> indexExpression,
|
||||
Expression<T> elementExpression) {
|
||||
return criteriaBuilder.arraySet( arrayExpression, indexExpression, elementExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T[]> arraySet(
|
||||
Expression<T[]> arrayExpression,
|
||||
Expression<Integer> indexExpression,
|
||||
T element) {
|
||||
return criteriaBuilder.arraySet( arrayExpression, indexExpression, element );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T[]> arraySet(
|
||||
Expression<T[]> arrayExpression,
|
||||
Integer index,
|
||||
Expression<T> elementExpression) {
|
||||
return criteriaBuilder.arraySet( arrayExpression, index, elementExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T[]> arraySet(Expression<T[]> arrayExpression, Integer index, T element) {
|
||||
return criteriaBuilder.arraySet( arrayExpression, index, element );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T[]> arrayRemove(Expression<T[]> arrayExpression, Expression<T> elementExpression) {
|
||||
return criteriaBuilder.arrayRemove( arrayExpression, elementExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T[]> arrayRemove(Expression<T[]> arrayExpression, T element) {
|
||||
return criteriaBuilder.arrayRemove( arrayExpression, element );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T[]> arrayRemoveIndex(
|
||||
Expression<T[]> arrayExpression,
|
||||
Expression<Integer> indexExpression) {
|
||||
return criteriaBuilder.arrayRemoveIndex( arrayExpression, indexExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T[]> arrayRemoveIndex(Expression<T[]> arrayExpression, Integer index) {
|
||||
return criteriaBuilder.arrayRemoveIndex( arrayExpression, index );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T[]> arraySlice(
|
||||
Expression<T[]> arrayExpression,
|
||||
Expression<Integer> lowerIndexExpression,
|
||||
Expression<Integer> upperIndexExpression) {
|
||||
return criteriaBuilder.arraySlice( arrayExpression, lowerIndexExpression, upperIndexExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T[]> arraySlice(
|
||||
Expression<T[]> arrayExpression,
|
||||
Expression<Integer> lowerIndexExpression,
|
||||
Integer upperIndex) {
|
||||
return criteriaBuilder.arraySlice( arrayExpression, lowerIndexExpression, upperIndex );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T[]> arraySlice(
|
||||
Expression<T[]> arrayExpression,
|
||||
Integer lowerIndex,
|
||||
Expression<Integer> upperIndexExpression) {
|
||||
return criteriaBuilder.arraySlice( arrayExpression, lowerIndex, upperIndexExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T[]> arraySlice(Expression<T[]> arrayExpression, Integer lowerIndex, Integer upperIndex) {
|
||||
return criteriaBuilder.arraySlice( arrayExpression, lowerIndex, upperIndex );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T[]> arrayReplace(
|
||||
Expression<T[]> arrayExpression,
|
||||
Expression<T> oldElementExpression,
|
||||
Expression<T> newElementExpression) {
|
||||
return criteriaBuilder.arrayReplace( arrayExpression, oldElementExpression, newElementExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T[]> arrayReplace(
|
||||
Expression<T[]> arrayExpression,
|
||||
Expression<T> oldElementExpression,
|
||||
T newElement) {
|
||||
return criteriaBuilder.arrayReplace( arrayExpression, oldElementExpression, newElement );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T[]> arrayReplace(
|
||||
Expression<T[]> arrayExpression,
|
||||
T oldElement,
|
||||
Expression<T> newElementExpression) {
|
||||
return criteriaBuilder.arrayReplace( arrayExpression, oldElement, newElementExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T[]> arrayReplace(Expression<T[]> arrayExpression, T oldElement, T newElement) {
|
||||
return criteriaBuilder.arrayReplace( arrayExpression, oldElement, newElement );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T[]> arrayTrim(
|
||||
Expression<T[]> arrayExpression,
|
||||
Expression<Integer> elementCountExpression) {
|
||||
return criteriaBuilder.arrayTrim( arrayExpression, elementCountExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T[]> arrayTrim(Expression<T[]> arrayExpression, Integer elementCount) {
|
||||
return criteriaBuilder.arrayTrim( arrayExpression, elementCount );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T[]> arrayFill(
|
||||
Expression<T> elementExpression,
|
||||
Expression<Integer> elementCountExpression) {
|
||||
return criteriaBuilder.arrayFill( elementExpression, elementCountExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T[]> arrayFill(Expression<T> elementExpression, Integer elementCount) {
|
||||
return criteriaBuilder.arrayFill( elementExpression, elementCount );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T[]> arrayFill(T element, Expression<Integer> elementCountExpression) {
|
||||
return criteriaBuilder.arrayFill( element, elementCountExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<T[]> arrayFill(T element, Integer elementCount) {
|
||||
return criteriaBuilder.arrayFill( element, elementCount );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<String> arrayToString(
|
||||
Expression<? extends Object[]> arrayExpression,
|
||||
Expression<String> separatorExpression) {
|
||||
return criteriaBuilder.arrayToString( arrayExpression, separatorExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<String> arrayToString(Expression<? extends Object[]> arrayExpression, String separator) {
|
||||
return criteriaBuilder.arrayToString( arrayExpression, separator );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaPredicate arrayContains(Expression<T[]> arrayExpression, Expression<T> elementExpression) {
|
||||
return criteriaBuilder.arrayContains( arrayExpression, elementExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaPredicate arrayContains(Expression<T[]> arrayExpression, T element) {
|
||||
return criteriaBuilder.arrayContains( arrayExpression, element );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaPredicate arrayContains(T[] array, Expression<T> elementExpression) {
|
||||
return criteriaBuilder.arrayContains( array, elementExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaPredicate arrayContainsNullable(Expression<T[]> arrayExpression, Expression<T> elementExpression) {
|
||||
return criteriaBuilder.arrayContainsNullable( arrayExpression, elementExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaPredicate arrayContainsNullable(Expression<T[]> arrayExpression, T element) {
|
||||
return criteriaBuilder.arrayContainsNullable( arrayExpression, element );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaPredicate arrayContainsNullable(T[] array, Expression<T> elementExpression) {
|
||||
return criteriaBuilder.arrayContainsNullable( array, elementExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaPredicate arrayContainsAll(Expression<T[]> arrayExpression, Expression<T[]> subArrayExpression) {
|
||||
return criteriaBuilder.arrayContainsAll( arrayExpression, subArrayExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaPredicate arrayContainsAll(Expression<T[]> arrayExpression, T[] subArray) {
|
||||
return criteriaBuilder.arrayContainsAll( arrayExpression, subArray );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaPredicate arrayContainsAll(T[] array, Expression<T[]> subArrayExpression) {
|
||||
return criteriaBuilder.arrayContainsAll( array, subArrayExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaPredicate arrayContainsAllNullable(
|
||||
Expression<T[]> arrayExpression,
|
||||
Expression<T[]> subArrayExpression) {
|
||||
return criteriaBuilder.arrayContainsAllNullable( arrayExpression, subArrayExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaPredicate arrayContainsAllNullable(Expression<T[]> arrayExpression, T[] subArray) {
|
||||
return criteriaBuilder.arrayContainsAllNullable( arrayExpression, subArray );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaPredicate arrayContainsAllNullable(T[] array, Expression<T[]> subArrayExpression) {
|
||||
return criteriaBuilder.arrayContainsAllNullable( array, subArrayExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaPredicate arrayOverlaps(Expression<T[]> arrayExpression1, Expression<T[]> arrayExpression2) {
|
||||
return criteriaBuilder.arrayOverlaps( arrayExpression1, arrayExpression2 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaPredicate arrayOverlaps(Expression<T[]> arrayExpression1, T[] array2) {
|
||||
return criteriaBuilder.arrayOverlaps( arrayExpression1, array2 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaPredicate arrayOverlaps(T[] array1, Expression<T[]> arrayExpression2) {
|
||||
return criteriaBuilder.arrayOverlaps( array1, arrayExpression2 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaPredicate arrayOverlapsNullable(Expression<T[]> arrayExpression1, Expression<T[]> arrayExpression2) {
|
||||
return criteriaBuilder.arrayOverlapsNullable( arrayExpression1, arrayExpression2 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaPredicate arrayOverlapsNullable(Expression<T[]> arrayExpression1, T[] array2) {
|
||||
return criteriaBuilder.arrayOverlapsNullable( arrayExpression1, array2 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaPredicate arrayOverlapsNullable(T[] array1, Expression<T[]> arrayExpression2) {
|
||||
return criteriaBuilder.arrayOverlapsNullable( array1, arrayExpression2 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E, C extends Collection<E>> JpaExpression<C> collectionLiteral(E... elements) {
|
||||
return criteriaBuilder.collectionLiteral( elements );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public JpaExpression<Integer> collectionLength(Expression<? extends Collection<?>> collectionExpression) {
|
||||
return criteriaBuilder.collectionLength( collectionExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E> JpaExpression<Integer> collectionPosition(
|
||||
Expression<? extends Collection<? extends E>> collectionExpression,
|
||||
E element) {
|
||||
return criteriaBuilder.collectionPosition( collectionExpression, element );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E> JpaExpression<Integer> collectionPosition(
|
||||
Expression<? extends Collection<? extends E>> collectionExpression,
|
||||
Expression<E> elementExpression) {
|
||||
return criteriaBuilder.collectionPosition( collectionExpression, elementExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<int[]> collectionPositions(
|
||||
Expression<? extends Collection<? super T>> collectionExpression,
|
||||
Expression<T> elementExpression) {
|
||||
return criteriaBuilder.collectionPositions( collectionExpression, elementExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<int[]> collectionPositions(
|
||||
Expression<? extends Collection<? super T>> collectionExpression,
|
||||
T element) {
|
||||
return criteriaBuilder.collectionPositions( collectionExpression, element );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<List<Integer>> collectionPositionsList(
|
||||
Expression<? extends Collection<? super T>> collectionExpression,
|
||||
Expression<T> elementExpression) {
|
||||
return criteriaBuilder.collectionPositionsList( collectionExpression, elementExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<List<Integer>> collectionPositionsList(
|
||||
Expression<? extends Collection<? super T>> collectionExpression,
|
||||
T element) {
|
||||
return criteriaBuilder.collectionPositionsList( collectionExpression, element );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E, C extends Collection<? super E>> JpaExpression<C> collectionConcat(
|
||||
Expression<C> collectionExpression1,
|
||||
Expression<? extends Collection<? extends E>> collectionExpression2) {
|
||||
return criteriaBuilder.collectionConcat( collectionExpression1, collectionExpression2 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E, C extends Collection<? super E>> JpaExpression<C> collectionConcat(
|
||||
Expression<C> collectionExpression1,
|
||||
Collection<? extends E> collection2) {
|
||||
return criteriaBuilder.collectionConcat( collectionExpression1, collection2 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E, C extends Collection<? super E>> JpaExpression<C> collectionConcat(
|
||||
C collection1,
|
||||
Expression<? extends Collection<? extends E>> collectionExpression2) {
|
||||
return criteriaBuilder.collectionConcat( collection1, collectionExpression2 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E, C extends Collection<? super E>> JpaExpression<C> collectionAppend(
|
||||
Expression<C> collectionExpression,
|
||||
Expression<? extends E> elementExpression) {
|
||||
return criteriaBuilder.collectionAppend( collectionExpression, elementExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E, C extends Collection<? super E>> JpaExpression<C> collectionAppend(
|
||||
Expression<C> collectionExpression,
|
||||
E element) {
|
||||
return criteriaBuilder.collectionAppend( collectionExpression, element );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E, C extends Collection<? super E>> JpaExpression<C> collectionPrepend(
|
||||
Expression<? extends E> elementExpression,
|
||||
Expression<C> collectionExpression) {
|
||||
return criteriaBuilder.collectionPrepend( elementExpression, collectionExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E, C extends Collection<? super E>> JpaExpression<C> collectionPrepend(
|
||||
E element,
|
||||
Expression<C> collectionExpression) {
|
||||
return criteriaBuilder.collectionPrepend( element, collectionExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E> JpaExpression<E> collectionGet(
|
||||
Expression<? extends Collection<E>> collectionExpression,
|
||||
Expression<Integer> indexExpression) {
|
||||
return criteriaBuilder.collectionGet( collectionExpression, indexExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E> JpaExpression<E> collectionGet(Expression<? extends Collection<E>> collectionExpression, Integer index) {
|
||||
return criteriaBuilder.collectionGet( collectionExpression, index );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E, C extends Collection<? super E>> JpaExpression<C> collectionSet(
|
||||
Expression<C> collectionExpression,
|
||||
Expression<Integer> indexExpression,
|
||||
Expression<? extends E> elementExpression) {
|
||||
return criteriaBuilder.collectionSet( collectionExpression, indexExpression, elementExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E, C extends Collection<? super E>> JpaExpression<C> collectionSet(
|
||||
Expression<C> collectionExpression,
|
||||
Expression<Integer> indexExpression,
|
||||
E element) {
|
||||
return criteriaBuilder.collectionSet( collectionExpression, indexExpression, element );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E, C extends Collection<? super E>> JpaExpression<C> collectionSet(
|
||||
Expression<C> collectionExpression,
|
||||
Integer index,
|
||||
Expression<? extends E> elementExpression) {
|
||||
return criteriaBuilder.collectionSet( collectionExpression, index, elementExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E, C extends Collection<? super E>> JpaExpression<C> collectionSet(
|
||||
Expression<C> collectionExpression,
|
||||
Integer index,
|
||||
E element) {
|
||||
return criteriaBuilder.collectionSet( collectionExpression, index, element );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E, C extends Collection<? super E>> JpaExpression<C> collectionRemove(
|
||||
Expression<C> collectionExpression,
|
||||
Expression<? extends E> elementExpression) {
|
||||
return criteriaBuilder.collectionRemove( collectionExpression, elementExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E, C extends Collection<? super E>> JpaExpression<C> collectionRemove(
|
||||
Expression<C> collectionExpression,
|
||||
E element) {
|
||||
return criteriaBuilder.collectionRemove( collectionExpression, element );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <C extends Collection<?>> JpaExpression<C> collectionRemoveIndex(
|
||||
Expression<C> collectionExpression,
|
||||
Expression<Integer> indexExpression) {
|
||||
return criteriaBuilder.collectionRemoveIndex( collectionExpression, indexExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <C extends Collection<?>> JpaExpression<C> collectionRemoveIndex(
|
||||
Expression<C> collectionExpression,
|
||||
Integer index) {
|
||||
return criteriaBuilder.collectionRemoveIndex( collectionExpression, index );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <C extends Collection<?>> JpaExpression<C> collectionSlice(
|
||||
Expression<C> collectionExpression,
|
||||
Expression<Integer> lowerIndexExpression,
|
||||
Expression<Integer> upperIndexExpression) {
|
||||
return criteriaBuilder.collectionSlice( collectionExpression, lowerIndexExpression, upperIndexExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <C extends Collection<?>> JpaExpression<C> collectionSlice(
|
||||
Expression<C> collectionExpression,
|
||||
Expression<Integer> lowerIndexExpression,
|
||||
Integer upperIndex) {
|
||||
return criteriaBuilder.collectionSlice( collectionExpression, lowerIndexExpression, upperIndex );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <C extends Collection<?>> JpaExpression<C> collectionSlice(
|
||||
Expression<C> collectionExpression,
|
||||
Integer lowerIndex,
|
||||
Expression<Integer> upperIndexExpression) {
|
||||
return criteriaBuilder.collectionSlice( collectionExpression, lowerIndex, upperIndexExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <C extends Collection<?>> JpaExpression<C> collectionSlice(
|
||||
Expression<C> collectionExpression,
|
||||
Integer lowerIndex,
|
||||
Integer upperIndex) {
|
||||
return criteriaBuilder.collectionSlice( collectionExpression, lowerIndex, upperIndex );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E, C extends Collection<? super E>> JpaExpression<C> collectionReplace(
|
||||
Expression<C> collectionExpression,
|
||||
Expression<? extends E> oldElementExpression,
|
||||
Expression<? extends E> newElementExpression) {
|
||||
return criteriaBuilder.collectionReplace( collectionExpression, oldElementExpression, newElementExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E, C extends Collection<? super E>> JpaExpression<C> collectionReplace(
|
||||
Expression<C> collectionExpression,
|
||||
Expression<? extends E> oldElementExpression,
|
||||
E newElement) {
|
||||
return criteriaBuilder.collectionReplace( collectionExpression, oldElementExpression, newElement );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E, C extends Collection<? super E>> JpaExpression<C> collectionReplace(
|
||||
Expression<C> collectionExpression,
|
||||
E oldElement,
|
||||
Expression<? extends E> newElementExpression) {
|
||||
return criteriaBuilder.collectionReplace( collectionExpression, oldElement, newElementExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E, C extends Collection<? super E>> JpaExpression<C> collectionReplace(
|
||||
Expression<C> collectionExpression,
|
||||
E oldElement,
|
||||
E newElement) {
|
||||
return criteriaBuilder.collectionReplace( collectionExpression, oldElement, newElement );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <C extends Collection<?>> JpaExpression<C> collectionTrim(
|
||||
Expression<C> arrayExpression,
|
||||
Expression<Integer> elementCountExpression) {
|
||||
return criteriaBuilder.collectionTrim( arrayExpression, elementCountExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <C extends Collection<?>> JpaExpression<C> collectionTrim(
|
||||
Expression<C> arrayExpression,
|
||||
Integer elementCount) {
|
||||
return criteriaBuilder.collectionTrim( arrayExpression, elementCount );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<Collection<T>> collectionFill(
|
||||
Expression<T> elementExpression,
|
||||
Expression<Integer> elementCountExpression) {
|
||||
return criteriaBuilder.collectionFill( elementExpression, elementCountExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<Collection<T>> collectionFill(Expression<T> elementExpression, Integer elementCount) {
|
||||
return criteriaBuilder.collectionFill( elementExpression, elementCount );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<Collection<T>> collectionFill(T element, Expression<Integer> elementCountExpression) {
|
||||
return criteriaBuilder.collectionFill( element, elementCountExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<Collection<T>> collectionFill(T element, Integer elementCount) {
|
||||
return criteriaBuilder.collectionFill( element, elementCount );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<String> collectionToString(
|
||||
Expression<? extends Collection<?>> collectionExpression,
|
||||
Expression<String> separatorExpression) {
|
||||
return criteriaBuilder.collectionToString( collectionExpression, separatorExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <T> JpaExpression<String> collectionToString(
|
||||
Expression<? extends Collection<?>> collectionExpression,
|
||||
String separator) {
|
||||
return criteriaBuilder.collectionToString( collectionExpression, separator );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E> JpaPredicate collectionContains(
|
||||
Expression<? extends Collection<E>> collectionExpression,
|
||||
Expression<? extends E> elementExpression) {
|
||||
return criteriaBuilder.collectionContains( collectionExpression, elementExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E> JpaPredicate collectionContains(Expression<? extends Collection<E>> collectionExpression, E element) {
|
||||
return criteriaBuilder.collectionContains( collectionExpression, element );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E> JpaPredicate collectionContains(Collection<E> collection, Expression<E> elementExpression) {
|
||||
return criteriaBuilder.collectionContains( collection, elementExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E> JpaPredicate collectionContainsNullable(
|
||||
Expression<? extends Collection<E>> collectionExpression,
|
||||
Expression<? extends E> elementExpression) {
|
||||
return criteriaBuilder.collectionContainsNullable( collectionExpression, elementExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E> JpaPredicate collectionContainsNullable(
|
||||
Expression<? extends Collection<E>> collectionExpression,
|
||||
E element) {
|
||||
return criteriaBuilder.collectionContainsNullable( collectionExpression, element );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E> JpaPredicate collectionContainsNullable(Collection<E> collection, Expression<E> elementExpression) {
|
||||
return criteriaBuilder.collectionContainsNullable( collection, elementExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E> JpaPredicate collectionContainsAll(
|
||||
Expression<? extends Collection<E>> collectionExpression,
|
||||
Expression<? extends Collection<? extends E>> subCollectionExpression) {
|
||||
return criteriaBuilder.collectionContainsAll( collectionExpression, subCollectionExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E> JpaPredicate collectionContainsAll(
|
||||
Expression<? extends Collection<E>> collectionExpression,
|
||||
Collection<? extends E> subCollection) {
|
||||
return criteriaBuilder.collectionContainsAll( collectionExpression, subCollection );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E> JpaPredicate collectionContainsAll(
|
||||
Collection<E> collection,
|
||||
Expression<? extends Collection<? extends E>> subArrayExpression) {
|
||||
return criteriaBuilder.collectionContainsAll( collection, subArrayExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E> JpaPredicate collectionContainsAllNullable(
|
||||
Expression<? extends Collection<E>> collectionExpression,
|
||||
Expression<? extends Collection<? extends E>> subCollectionExpression) {
|
||||
return criteriaBuilder.collectionContainsAllNullable( collectionExpression, subCollectionExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E> JpaPredicate collectionContainsAllNullable(
|
||||
Expression<? extends Collection<E>> collectionExpression,
|
||||
Collection<? extends E> subCollection) {
|
||||
return criteriaBuilder.collectionContainsAllNullable( collectionExpression, subCollection );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E> JpaPredicate collectionContainsAllNullable(
|
||||
Collection<E> collection,
|
||||
Expression<? extends Collection<? extends E>> subCollectionExpression) {
|
||||
return criteriaBuilder.collectionContainsAllNullable( collection, subCollectionExpression );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E> JpaPredicate collectionOverlaps(
|
||||
Expression<? extends Collection<E>> collectionExpression1,
|
||||
Expression<? extends Collection<? extends E>> collectionExpression2) {
|
||||
return criteriaBuilder.collectionOverlaps( collectionExpression1, collectionExpression2 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E> JpaPredicate collectionOverlaps(
|
||||
Expression<? extends Collection<E>> collectionExpression1,
|
||||
Collection<? extends E> collection2) {
|
||||
return criteriaBuilder.collectionOverlaps( collectionExpression1, collection2 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E> JpaPredicate collectionOverlaps(
|
||||
Collection<E> collection1,
|
||||
Expression<? extends Collection<? extends E>> collectionExpression2) {
|
||||
return criteriaBuilder.collectionOverlaps( collection1, collectionExpression2 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E> JpaPredicate collectionOverlapsNullable(
|
||||
Expression<? extends Collection<E>> collectionExpression1,
|
||||
Expression<? extends Collection<? extends E>> collectionExpression2) {
|
||||
return criteriaBuilder.collectionOverlapsNullable( collectionExpression1, collectionExpression2 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E> JpaPredicate collectionOverlapsNullable(
|
||||
Expression<? extends Collection<E>> collectionExpression1,
|
||||
Collection<? extends E> collection2) {
|
||||
return criteriaBuilder.collectionOverlapsNullable( collectionExpression1, collection2 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Incubating
|
||||
public <E> JpaPredicate collectionOverlapsNullable(
|
||||
Collection<E> collection1,
|
||||
Expression<? extends Collection<? extends E>> collectionExpression2) {
|
||||
return criteriaBuilder.collectionOverlapsNullable( collection1, collectionExpression2 );
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -268,7 +268,10 @@ public class StandardFunctionReturnTypeResolvers {
|
|||
}
|
||||
|
||||
private static SqmExpressible<?> getArgumentExpressible(SqmTypedNode<?> specifiedArgument) {
|
||||
final SqmExpressible<?> specifiedArgType = specifiedArgument.getNodeType();
|
||||
final SqmExpressible<?> expressible = specifiedArgument.getNodeType();
|
||||
final SqmExpressible<?> specifiedArgType = expressible instanceof SqmTypedNode<?>
|
||||
? ( (SqmTypedNode<?>) expressible ).getNodeType()
|
||||
: expressible;
|
||||
return specifiedArgType instanceof SqmPathSource ?
|
||||
( (SqmPathSource<?>) specifiedArgType ).getSqmPathType() :
|
||||
specifiedArgType;
|
||||
|
|
|
@ -17,6 +17,9 @@ import org.hibernate.cfg.AvailableSettings;
|
|||
import org.hibernate.dialect.OracleArrayJdbcType;
|
||||
import org.hibernate.dialect.SpannerDialect;
|
||||
import org.hibernate.engine.jdbc.Size;
|
||||
import org.hibernate.query.criteria.JpaCriteriaQuery;
|
||||
import org.hibernate.query.criteria.JpaRoot;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
import org.hibernate.type.SqlTypes;
|
||||
import org.hibernate.type.descriptor.java.ArrayJavaType;
|
||||
import org.hibernate.type.descriptor.java.spi.JavaTypeRegistry;
|
||||
|
@ -145,4 +148,17 @@ public class ArrayAggregateTest {
|
|||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilder(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<String[]> cq = cb.createQuery( String[].class );
|
||||
final JpaRoot<EntityOfBasics> root = cq.from( EntityOfBasics.class );
|
||||
cq.select( cb.arrayAgg( cb.asc( root.get( "theString" ), false ), root.get( "theString" ) ) );
|
||||
List<String[]> results = em.createQuery( cq ).getResultList();
|
||||
assertEquals( 1, results.size() );
|
||||
assertArrayEquals( new String[]{ "abc", "def", null }, results.get( 0 ) );
|
||||
} );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,10 +6,16 @@
|
|||
*/
|
||||
package org.hibernate.orm.test.function.array;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.query.criteria.JpaCriteriaQuery;
|
||||
import org.hibernate.query.criteria.JpaRoot;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
|
||||
import org.hibernate.testing.orm.domain.gambit.EntityOfBasics;
|
||||
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
|
||||
|
@ -22,6 +28,7 @@ import org.junit.jupiter.api.BeforeEach;
|
|||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jakarta.persistence.Tuple;
|
||||
import jakarta.persistence.criteria.Expression;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
@ -87,4 +94,42 @@ public class ArrayAppendTest {
|
|||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderArray(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.arrayAppend( root.<String[]>get( "theArray" ), cb.literal( "xyz" ) ),
|
||||
cb.arrayAppend( root.get( "theArray" ), "xyz" )
|
||||
);
|
||||
em.createQuery( cq ).getResultList();
|
||||
|
||||
// Should all fail to compile
|
||||
// cb.arrayAppend( root.<Integer[]>get( "theArray" ), cb.literal( "xyz" ) );
|
||||
// cb.arrayAppend( root.<Integer[]>get( "theArray" ), "xyz" );
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderCollection(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.collectionAppend( root.<Collection<String>>get( "theCollection" ), cb.literal( "xyz" ) ),
|
||||
cb.collectionAppend( root.get( "theCollection" ), "xyz" )
|
||||
);
|
||||
em.createQuery( cq ).getResultList();
|
||||
|
||||
// Should all fail to compile
|
||||
// cb.collectionAppend( root.<Collection<Integer>>get( "theCollection" ), cb.literal( "xyz" ) );
|
||||
// cb.collectionAppend( root.<Collection<Integer>>get( "theCollection" ), "xyz" );
|
||||
} );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,9 +6,14 @@
|
|||
*/
|
||||
package org.hibernate.orm.test.function.array;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.query.criteria.JpaCriteriaQuery;
|
||||
import org.hibernate.query.criteria.JpaRoot;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
|
@ -171,4 +176,46 @@ public class ArrayConcatTest {
|
|||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderArray(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.arrayConcat( root.get( "theArray" ), cb.arrayLiteral( "xyz" ) ),
|
||||
cb.arrayConcat( root.get( "theArray" ), new String[]{ "xyz" } ),
|
||||
cb.arrayConcat( new String[]{ "xyz" }, root.get( "theArray" ) )
|
||||
);
|
||||
em.createQuery( cq ).getResultList();
|
||||
|
||||
// Should all fail to compile
|
||||
// cb.arrayConcat( root.<Integer[]>get( "theArray" ), cb.literal( new String[]{ "xyz" } ) );
|
||||
// cb.arrayConcat( root.<Integer[]>get( "theArray" ), new String[]{ "xyz" } );
|
||||
// cb.arrayConcat( new String[]{ "xyz" }, root.<Integer[]>get( "theArray" ) );
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderCollection(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.collectionConcat( root.get( "theCollection" ), cb.collectionLiteral( "xyz" ) ),
|
||||
cb.collectionConcat( root.get( "theCollection" ), List.of( "xyz" ) ),
|
||||
cb.collectionConcat( List.of( "xyz" ), root.get( "theCollection" ) )
|
||||
);
|
||||
em.createQuery( cq ).getResultList();
|
||||
|
||||
// Should all fail to compile
|
||||
// cb.collectionConcat( root.<Collection<Integer>>get( "theCollection" ), cb.literal( List.of( "xyz" ) ) );
|
||||
// cb.collectionConcat( root.<Collection<Integer>>get( "theCollection" ), List.of( "xyz" ) );
|
||||
// cb.collectionConcat( List.of( "xyz" ), root.<Collection<Integer>>get( "theCollection" ) );
|
||||
} );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,9 +6,13 @@
|
|||
*/
|
||||
package org.hibernate.orm.test.function.array;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.query.criteria.JpaCriteriaQuery;
|
||||
import org.hibernate.query.criteria.JpaRoot;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
|
@ -21,6 +25,8 @@ import org.junit.jupiter.api.AfterEach;
|
|||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jakarta.persistence.Tuple;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
|
@ -71,14 +77,36 @@ public class ArrayConstructorTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testMultipleArguments(SessionFactoryScope scope) {
|
||||
public void testNodeBuilderArray(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
//tag::hql-array-example[]
|
||||
List<EntityWithArrays> results = em.createQuery( "from EntityWithArrays e where e.theArray is not distinct from array('abc', null, 'def')", EntityWithArrays.class )
|
||||
.getResultList();
|
||||
//end::hql-array-example[]
|
||||
assertEquals( 1, results.size() );
|
||||
assertEquals( 2L, results.get( 0 ).getId() );
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.arrayLiteral( "xyz" )
|
||||
);
|
||||
final List<Tuple> result = em.createQuery( cq ).getResultList();
|
||||
assertEquals( 3, result.size() );
|
||||
assertEquals( 1, result.get( 0 ).get( 1, String[].class ).length );
|
||||
assertEquals( "xyz", result.get( 0 ).get( 1, String[].class )[0] );
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderCollection(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.collectionLiteral( "xyz" )
|
||||
);
|
||||
final List<Tuple> result = em.createQuery( cq ).getResultList();
|
||||
assertEquals( 3, result.size() );
|
||||
assertEquals( 1, result.get( 0 ).get( 1, Collection.class ).size() );
|
||||
assertEquals( "xyz", result.get( 0 ).get( 1, Collection.class ).iterator().next() );
|
||||
} );
|
||||
}
|
||||
|
||||
|
|
|
@ -6,10 +6,15 @@
|
|||
*/
|
||||
package org.hibernate.orm.test.function.array;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.dialect.HSQLDialect;
|
||||
import org.hibernate.query.criteria.JpaCriteriaQuery;
|
||||
import org.hibernate.query.criteria.JpaRoot;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
|
@ -23,6 +28,9 @@ import org.junit.jupiter.api.AfterEach;
|
|||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jakarta.persistence.Tuple;
|
||||
import jakarta.persistence.criteria.Expression;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
|
@ -140,4 +148,62 @@ public class ArrayContainsArrayTest {
|
|||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderArray(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.arrayContainsAll( root.get( "theArray" ), cb.arrayLiteral( "xyz" ) ),
|
||||
cb.arrayContainsAll( root.get( "theArray" ), new String[]{ "xyz" } ),
|
||||
cb.arrayContainsAll( new String[]{ "abc", "xyz" }, cb.arrayLiteral( "xyz" ) ),
|
||||
cb.arrayContainsAllNullable( root.get( "theArray" ), cb.arrayLiteral( "xyz" ) ),
|
||||
cb.arrayContainsAllNullable( root.get( "theArray" ), new String[]{ "xyz" } ),
|
||||
cb.arrayContainsAllNullable( new String[]{ "abc", "xyz" }, cb.arrayLiteral( "xyz" ) )
|
||||
);
|
||||
em.createQuery( cq ).getResultList();
|
||||
|
||||
// Should all fail to compile
|
||||
// cb.arrayContainsAll( root.<Integer[]>get( "theArray" ), cb.arrayLiteral( "xyz" ) );
|
||||
// cb.arrayContainsAll( root.<Integer[]>get( "theArray" ), new String[]{ "xyz" } );
|
||||
// cb.arrayContainsAll( new String[0], cb.literal( 1 ) );
|
||||
// cb.arrayContainsAll( new Integer[0], cb.literal( "" ) );
|
||||
// cb.arrayContainsAllNullable( root.<Integer[]>get( "theArray" ), cb.arrayLiteral( "xyz" ) );
|
||||
// cb.arrayContainsAllNullable( root.<Integer[]>get( "theArray" ), new String[]{ "xyz" } );
|
||||
// cb.arrayContainsAllNullable( new String[0], cb.literal( 1 ) );
|
||||
// cb.arrayContainsAllNullable( new Integer[0], cb.literal( "" ) );
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderCollection(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.collectionContainsAll( root.<Collection<String>>get( "theCollection" ), cb.collectionLiteral( "xyz" ) ),
|
||||
cb.collectionContainsAll( root.get( "theCollection" ), List.of( "xyz" ) ),
|
||||
cb.collectionContainsAll( List.of( "abc", "xyz" ), cb.collectionLiteral( "xyz" ) ),
|
||||
cb.collectionContainsAllNullable( root.<Collection<String>>get( "theCollection" ), cb.collectionLiteral( "xyz" ) ),
|
||||
cb.collectionContainsAllNullable( root.get( "theCollection" ), List.of( "xyz" ) ),
|
||||
cb.collectionContainsAllNullable( List.of( "abc", "xyz" ), cb.collectionLiteral( "xyz" ) )
|
||||
);
|
||||
em.createQuery( cq ).getResultList();
|
||||
|
||||
// Should all fail to compile
|
||||
// cb.collectionContainsAll( root.<Collection<Integer>>get( "theCollection" ), cb.collectionLiteral( "xyz" ) );
|
||||
// cb.collectionContainsAll( root.<Collection<Integer>>get( "theCollection" ), List.of( "xyz" ) );
|
||||
// cb.collectionContainsAll( Collections.<String>emptyList(), cb.literal( 1 ) );
|
||||
// cb.collectionContainsAll( Collections.<Integer>emptyList(), cb.literal( "" ) );
|
||||
// cb.collectionContainsAllNullable( root.<Collection<Integer>>get( "theCollection" ), cb.collectionLiteral( "xyz" ) );
|
||||
// cb.collectionContainsAllNullable( root.<Collection<Integer>>get( "theCollection" ), List.of( "xyz" ) );
|
||||
// cb.collectionContainsAllNullable( Collections.<String>emptyList(), cb.literal( 1 ) );
|
||||
// cb.collectionContainsAllNullable( Collections.<Integer>emptyList(), cb.literal( "" ) );
|
||||
} );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,9 +6,14 @@
|
|||
*/
|
||||
package org.hibernate.orm.test.function.array;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.query.criteria.JpaCriteriaQuery;
|
||||
import org.hibernate.query.criteria.JpaRoot;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
|
@ -21,6 +26,9 @@ import org.junit.jupiter.api.AfterEach;
|
|||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jakarta.persistence.Tuple;
|
||||
import jakarta.persistence.criteria.Expression;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
|
@ -72,4 +80,62 @@ public class ArrayContainsTest {
|
|||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderArray(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.arrayContains( root.<String[]>get( "theArray" ), cb.literal( "xyz" ) ),
|
||||
cb.arrayContains( root.get( "theArray" ), "xyz" ),
|
||||
cb.arrayContains( new String[]{ "abc", "xyz" }, cb.literal( "xyz" ) ),
|
||||
cb.arrayContainsNullable( root.<String[]>get( "theArray" ), cb.literal( "xyz" ) ),
|
||||
cb.arrayContainsNullable( root.get( "theArray" ), "xyz" ),
|
||||
cb.arrayContainsNullable( new String[]{ "abc", "xyz" }, cb.literal( "xyz" ) )
|
||||
);
|
||||
em.createQuery( cq ).getResultList();
|
||||
|
||||
// Should all fail to compile
|
||||
// cb.arrayContains( root.<Integer[]>get( "theArray" ), cb.literal( "xyz" ) );
|
||||
// cb.arrayContains( root.<Integer[]>get( "theArray" ), "xyz" );
|
||||
// cb.arrayContains( new String[]{ "abc", "xyz" }, cb.<Integer>literal( 1 ) );
|
||||
// cb.arrayContains( new Integer[0], cb.<String>literal( "" ) );
|
||||
// cb.arrayContainsNullable( root.<Integer[]>get( "theArray" ), cb.literal( "xyz" ) );
|
||||
// cb.arrayContainsNullable( root.<Integer[]>get( "theArray" ), "xyz" );
|
||||
// cb.arrayContainsNullable( new String[]{ "abc", "xyz" }, cb.<Integer>literal( 1 ) );
|
||||
// cb.arrayContainsNullable( new Integer[0], cb.<String>literal( "" ) );
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderCollection(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.collectionContains( root.<Collection<String>>get( "theCollection" ), cb.literal( "xyz" ) ),
|
||||
cb.collectionContains( root.get( "theCollection" ), "xyz" ),
|
||||
cb.collectionContains( List.of( "abc", "xyz" ), cb.literal( "xyz" ) ),
|
||||
cb.collectionContainsNullable( root.<Collection<String>>get( "theCollection" ), cb.literal( "xyz" ) ),
|
||||
cb.collectionContainsNullable( root.get( "theCollection" ), "xyz" ),
|
||||
cb.collectionContainsNullable( List.of( "abc", "xyz" ), cb.literal( "xyz" ) )
|
||||
);
|
||||
em.createQuery( cq ).getResultList();
|
||||
|
||||
// Should all fail to compile
|
||||
// cb.collectionContains( root.<Collection<Integer>>get( "theCollection" ), cb.literal( "xyz" ) );
|
||||
// cb.collectionContains( root.<Collection<Integer>>get( "theCollection" ), "xyz" );
|
||||
// cb.collectionContains( List.of( "abc", "xyz" ), cb.<Integer>literal( 1 ) );
|
||||
// cb.collectionContains( Collections.<Integer>emptyList(), cb.<String>literal( "" ) );
|
||||
// cb.collectionContainsNullable( root.<Collection<Integer>>get( "theCollection" ), cb.literal( "xyz" ) );
|
||||
// cb.collectionContainsNullable( root.<Collection<Integer>>get( "theCollection" ), "xyz" );
|
||||
// cb.collectionContainsNullable( List.of( "abc", "xyz" ), cb.<Integer>literal( 1 ) );
|
||||
// cb.collectionContainsNullable( Collections.<Integer>emptyList(), cb.<String>literal( "" ) );
|
||||
} );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,9 +6,13 @@
|
|||
*/
|
||||
package org.hibernate.orm.test.function.array;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.query.criteria.JpaCriteriaQuery;
|
||||
import org.hibernate.query.criteria.JpaRoot;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
|
@ -21,6 +25,8 @@ import org.junit.jupiter.api.AfterEach;
|
|||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jakarta.persistence.Tuple;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
|
@ -84,4 +90,50 @@ public class ArrayFillTest {
|
|||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderArray(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.arrayFill( cb.literal( "xyz" ), cb.literal( 2 ) ),
|
||||
cb.arrayFill( cb.literal( "xyz" ), 2 ),
|
||||
cb.arrayFill( "xyz", cb.literal( 2 ) ),
|
||||
cb.arrayFill( "xyz", 2 )
|
||||
);
|
||||
final List<Tuple> result = em.createQuery( cq ).getResultList();
|
||||
final String[] expected = new String[]{ "xyz", "xyz" };
|
||||
assertEquals( 3, result.size() );
|
||||
assertArrayEquals( expected, result.get( 0 ).get( 1, String[].class ) );
|
||||
assertArrayEquals( expected, result.get( 0 ).get( 2, String[].class ) );
|
||||
assertArrayEquals( expected, result.get( 0 ).get( 3, String[].class ) );
|
||||
assertArrayEquals( expected, result.get( 0 ).get( 4, String[].class ) );
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderCollection(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.collectionFill( cb.literal( "xyz" ), cb.literal( 2 ) ),
|
||||
cb.collectionFill( cb.literal( "xyz" ), 2 ),
|
||||
cb.collectionFill( "xyz", cb.literal( 2 ) ),
|
||||
cb.collectionFill( "xyz", 2 )
|
||||
);
|
||||
final List<Tuple> result = em.createQuery( cq ).getResultList();
|
||||
final List<String> expected = List.of( "xyz", "xyz" );
|
||||
assertEquals( 3, result.size() );
|
||||
assertEquals( expected, result.get( 0 ).get( 1, Collection.class ) );
|
||||
assertEquals( expected, result.get( 0 ).get( 2, Collection.class ) );
|
||||
assertEquals( expected, result.get( 0 ).get( 3, Collection.class ) );
|
||||
assertEquals( expected, result.get( 0 ).get( 4, Collection.class ) );
|
||||
} );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,9 +6,13 @@
|
|||
*/
|
||||
package org.hibernate.orm.test.function.array;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.query.criteria.JpaCriteriaQuery;
|
||||
import org.hibernate.query.criteria.JpaRoot;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
|
@ -21,6 +25,8 @@ import org.junit.jupiter.api.AfterEach;
|
|||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jakarta.persistence.Tuple;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
|
@ -82,4 +88,34 @@ public class ArrayGetTest {
|
|||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderArray(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.arrayGet( root.get( "theArray" ), cb.literal( 1 ) ),
|
||||
cb.arrayGet( root.get( "theArray" ), 1 )
|
||||
);
|
||||
em.createQuery( cq ).getResultList();
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderCollection(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.collectionGet( root.get( "theCollection" ), cb.literal( 1 ) ),
|
||||
cb.collectionGet( root.get( "theCollection" ), 1 )
|
||||
);
|
||||
em.createQuery( cq ).getResultList();
|
||||
} );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,9 +6,13 @@
|
|||
*/
|
||||
package org.hibernate.orm.test.function.array;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.query.criteria.JpaCriteriaQuery;
|
||||
import org.hibernate.query.criteria.JpaRoot;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
|
@ -21,6 +25,8 @@ import org.junit.jupiter.api.AfterEach;
|
|||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jakarta.persistence.Tuple;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
|
@ -83,4 +89,32 @@ public class ArrayLengthTest {
|
|||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderArray(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.arrayLength( root.get( "theArray" ) )
|
||||
);
|
||||
em.createQuery( cq ).getResultList();
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderCollection(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.collectionLength( root.get( "theCollection" ) )
|
||||
);
|
||||
em.createQuery( cq ).getResultList();
|
||||
} );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,10 +6,15 @@
|
|||
*/
|
||||
package org.hibernate.orm.test.function.array;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.dialect.HSQLDialect;
|
||||
import org.hibernate.query.criteria.JpaCriteriaQuery;
|
||||
import org.hibernate.query.criteria.JpaRoot;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
|
@ -23,6 +28,8 @@ import org.junit.jupiter.api.AfterEach;
|
|||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jakarta.persistence.Tuple;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
|
@ -106,4 +113,62 @@ public class ArrayOverlapsTest {
|
|||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderArray(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.arrayOverlaps( root.get( "theArray" ), cb.arrayLiteral( "xyz" ) ),
|
||||
cb.arrayOverlaps( root.get( "theArray" ), new String[]{ "xyz" } ),
|
||||
cb.arrayOverlaps( new String[]{ "abc", "xyz" }, cb.arrayLiteral( "xyz" ) ),
|
||||
cb.arrayOverlapsNullable( root.get( "theArray" ), cb.arrayLiteral( "xyz" ) ),
|
||||
cb.arrayOverlapsNullable( root.get( "theArray" ), new String[]{ "xyz" } ),
|
||||
cb.arrayOverlapsNullable( new String[]{ "abc", "xyz" }, cb.arrayLiteral( "xyz" ) )
|
||||
);
|
||||
em.createQuery( cq ).getResultList();
|
||||
|
||||
// Should all fail to compile
|
||||
// cb.arrayOverlaps( root.<Integer[]>get( "theArray" ), cb.arrayLiteral( "xyz" ) );
|
||||
// cb.arrayOverlaps( root.<Integer[]>get( "theArray" ), new String[]{ "xyz" } );
|
||||
// cb.arrayOverlaps( new String[0], cb.literal( 1 ) );
|
||||
// cb.arrayOverlaps( new Integer[0], cb.literal( "" ) );
|
||||
// cb.arrayOverlapsNullable( root.<Integer[]>get( "theArray" ), cb.arrayLiteral( "xyz" ) );
|
||||
// cb.arrayOverlapsNullable( root.<Integer[]>get( "theArray" ), new String[]{ "xyz" } );
|
||||
// cb.arrayOverlapsNullable( new String[0], cb.literal( 1 ) );
|
||||
// cb.arrayOverlapsNullable( new Integer[0], cb.literal( "" ) );
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderCollection(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.collectionOverlaps( root.<Collection<String>>get( "theCollection" ), cb.collectionLiteral( "xyz" ) ),
|
||||
cb.collectionOverlaps( root.get( "theCollection" ), List.of( "xyz" ) ),
|
||||
cb.collectionOverlaps( List.of( "abc", "xyz" ), cb.collectionLiteral( "xyz" ) ),
|
||||
cb.collectionOverlapsNullable( root.<Collection<String>>get( "theCollection" ), cb.collectionLiteral( "xyz" ) ),
|
||||
cb.collectionOverlapsNullable( root.get( "theCollection" ), List.of( "xyz" ) ),
|
||||
cb.collectionOverlapsNullable( List.of( "abc", "xyz" ), cb.collectionLiteral( "xyz" ) )
|
||||
);
|
||||
em.createQuery( cq ).getResultList();
|
||||
|
||||
// Should all fail to compile
|
||||
// cb.collectionOverlaps( root.<Collection<Integer>>get( "theCollection" ), cb.collectionLiteral( "xyz" ) );
|
||||
// cb.collectionOverlaps( root.<Collection<Integer>>get( "theCollection" ), List.of( "xyz" ) );
|
||||
// cb.collectionOverlaps( Collections.<String>emptyList(), cb.literal( 1 ) );
|
||||
// cb.collectionOverlaps( Collections.<Integer>emptyList(), cb.literal( "" ) );
|
||||
// cb.collectionOverlapsNullable( root.<Collection<Integer>>get( "theCollection" ), cb.collectionLiteral( "xyz" ) );
|
||||
// cb.collectionOverlapsNullable( root.<Collection<Integer>>get( "theCollection" ), List.of( "xyz" ) );
|
||||
// cb.collectionOverlapsNullable( Collections.<String>emptyList(), cb.literal( 1 ) );
|
||||
// cb.collectionOverlapsNullable( Collections.<Integer>emptyList(), cb.literal( "" ) );
|
||||
} );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,9 +6,14 @@
|
|||
*/
|
||||
package org.hibernate.orm.test.function.array;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.query.criteria.JpaCriteriaQuery;
|
||||
import org.hibernate.query.criteria.JpaRoot;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
|
@ -21,6 +26,8 @@ import org.junit.jupiter.api.AfterEach;
|
|||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jakarta.persistence.Tuple;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
|
@ -82,4 +89,42 @@ public class ArrayPositionTest {
|
|||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderArray(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.arrayPosition( root.<String[]>get( "theArray" ), cb.literal( "xyz" ) ),
|
||||
cb.arrayPosition( root.get( "theArray" ), "xyz" )
|
||||
);
|
||||
em.createQuery( cq ).getResultList();
|
||||
|
||||
// Should all fail to compile
|
||||
// cb.arrayPosition( root.<Integer[]>get( "theArray" ), cb.literal( "xyz" ) );
|
||||
// cb.arrayPosition( root.<Integer[]>get( "theArray" ), "xyz" );
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderCollection(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.collectionPosition( root.<Collection<String>>get( "theCollection" ), cb.literal( "xyz" ) ),
|
||||
cb.collectionPosition( root.get( "theCollection" ), "xyz" )
|
||||
);
|
||||
em.createQuery( cq ).getResultList();
|
||||
|
||||
// Should all fail to compile
|
||||
// cb.collectionPosition( root.<Collection<Integer>>get( "theCollection" ), cb.literal( "xyz" ) );
|
||||
// cb.collectionPosition( root.<Collection<Integer>>get( "theCollection" ), "xyz" );
|
||||
} );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,9 +6,13 @@
|
|||
*/
|
||||
package org.hibernate.orm.test.function.array;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.query.criteria.JpaCriteriaQuery;
|
||||
import org.hibernate.query.criteria.JpaRoot;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
|
@ -21,6 +25,8 @@ import org.junit.jupiter.api.AfterEach;
|
|||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jakarta.persistence.Tuple;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
@ -103,4 +109,50 @@ public class ArrayPositionsTest {
|
|||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderArray(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.arrayPositions( root.<String[]>get( "theArray" ), cb.literal( "xyz" ) ),
|
||||
cb.arrayPositions( root.get( "theArray" ), "xyz" ),
|
||||
cb.arrayPositionsList( root.<String[]>get( "theArray" ), cb.literal( "xyz" ) ),
|
||||
cb.arrayPositionsList( root.get( "theArray" ), "xyz" )
|
||||
);
|
||||
em.createQuery( cq ).getResultList();
|
||||
|
||||
// Should all fail to compile
|
||||
// cb.arrayPositions( root.<Integer[]>get( "theArray" ), cb.literal( "xyz" ) );
|
||||
// cb.arrayPositions( root.<Integer[]>get( "theArray" ), "xyz" );
|
||||
// cb.arrayPositionsList( root.<Integer[]>get( "theArray" ), cb.literal( "xyz" ) );
|
||||
// cb.arrayPositionsList( root.<Integer[]>get( "theArray" ), "xyz" );
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderCollection(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.collectionPositions( root.<Collection<String>>get( "theCollection" ), cb.literal( "xyz" ) ),
|
||||
cb.collectionPositions( root.get( "theCollection" ), "xyz" ),
|
||||
cb.collectionPositionsList( root.<Collection<String>>get( "theCollection" ), cb.literal( "xyz" ) ),
|
||||
cb.collectionPositionsList( root.get( "theCollection" ), "xyz" )
|
||||
);
|
||||
em.createQuery( cq ).getResultList();
|
||||
|
||||
// Should all fail to compile
|
||||
// cb.collectionPositions( root.<Collection<Integer>>get( "theCollection" ), cb.literal( "xyz" ) );
|
||||
// cb.collectionPositions( root.<Collection<Integer>>get( "theCollection" ), "xyz" );
|
||||
// cb.collectionPositionsList( root.<Collection<Integer>>get( "theCollection" ), cb.literal( "xyz" ) );
|
||||
// cb.collectionPositionsList( root.<Collection<Integer>>get( "theCollection" ), "xyz" );
|
||||
} );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,9 +6,14 @@
|
|||
*/
|
||||
package org.hibernate.orm.test.function.array;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.query.criteria.JpaCriteriaQuery;
|
||||
import org.hibernate.query.criteria.JpaRoot;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
|
@ -87,4 +92,42 @@ public class ArrayPrependTest {
|
|||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderArray(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.arrayPrepend( cb.literal( "xyz" ), root.<String[]>get( "theArray" ) ),
|
||||
cb.arrayPrepend( "xyz", root.get( "theArray" ) )
|
||||
);
|
||||
em.createQuery( cq ).getResultList();
|
||||
|
||||
// Should all fail to compile
|
||||
// cb.arrayPrepend( root.<Integer[]>get( "theArray" ), cb.literal( "xyz" ) );
|
||||
// cb.arrayPrepend( root.<Integer[]>get( "theArray" ), "xyz" );
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderCollection(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.collectionPrepend( cb.literal( "xyz" ), root.<Collection<String>>get( "theCollection" ) ),
|
||||
cb.collectionPrepend( "xyz", root.get( "theCollection" ) )
|
||||
);
|
||||
em.createQuery( cq ).getResultList();
|
||||
|
||||
// Should all fail to compile
|
||||
// cb.collectionPrepend( cb.literal( "xyz" ), root.<Collection<Integer>>get( "theCollection" ) );
|
||||
// cb.collectionPrepend( "xyz", root.<Collection<Integer>>get( "theCollection" ) );
|
||||
} );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,9 +6,13 @@
|
|||
*/
|
||||
package org.hibernate.orm.test.function.array;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.query.criteria.JpaCriteriaQuery;
|
||||
import org.hibernate.query.criteria.JpaRoot;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
|
@ -102,4 +106,34 @@ public class ArrayRemoveIndexTest {
|
|||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderArray(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.arrayRemoveIndex( root.<String[]>get( "theArray" ), cb.literal( 1 ) ),
|
||||
cb.arrayRemoveIndex( root.get( "theArray" ), 1 )
|
||||
);
|
||||
em.createQuery( cq ).getResultList();
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderCollection(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.collectionRemoveIndex( root.<Collection<String>>get( "theCollection" ), cb.literal( 1 ) ),
|
||||
cb.collectionRemoveIndex( root.get( "theCollection" ), 1 )
|
||||
);
|
||||
em.createQuery( cq ).getResultList();
|
||||
} );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,9 +6,13 @@
|
|||
*/
|
||||
package org.hibernate.orm.test.function.array;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.query.criteria.JpaCriteriaQuery;
|
||||
import org.hibernate.query.criteria.JpaRoot;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
|
@ -102,4 +106,42 @@ public class ArrayRemoveTest {
|
|||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderArray(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.arrayRemove( root.<String[]>get( "theArray" ), cb.literal( "xyz" ) ),
|
||||
cb.arrayRemove( root.get( "theArray" ), "xyz" )
|
||||
);
|
||||
em.createQuery( cq ).getResultList();
|
||||
|
||||
// Should all fail to compile
|
||||
// cb.arrayRemove( root.<Integer[]>get( "theArray" ), cb.literal( "xyz" ) );
|
||||
// cb.arrayRemove( root.<Integer[]>get( "theArray" ), "xyz" );
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderCollection(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.collectionRemove( root.<Collection<String>>get( "theCollection" ), cb.literal( "xyz" ) ),
|
||||
cb.collectionRemove( root.get( "theCollection" ), "xyz" )
|
||||
);
|
||||
em.createQuery( cq ).getResultList();
|
||||
|
||||
// Should all fail to compile
|
||||
// cb.collectionRemove( root.<Collection<Integer>>get( "theCollection" ), cb.literal( "xyz" ) );
|
||||
// cb.collectionRemove( root.<Collection<Integer>>get( "theCollection" ), "xyz" );
|
||||
} );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,9 +6,13 @@
|
|||
*/
|
||||
package org.hibernate.orm.test.function.array;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.query.criteria.JpaCriteriaQuery;
|
||||
import org.hibernate.query.criteria.JpaRoot;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
|
@ -102,4 +106,50 @@ public class ArrayReplaceTest {
|
|||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderArray(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.arrayReplace( root.<String[]>get( "theArray" ), cb.literal( "abc" ), cb.literal( "xyz" ) ),
|
||||
cb.arrayReplace( root.<String[]>get( "theArray" ), cb.literal( "abc" ), "xyz" ),
|
||||
cb.arrayReplace( root.<String[]>get( "theArray" ), "abc", cb.literal( "xyz" ) ),
|
||||
cb.arrayReplace( root.get( "theArray" ), "abc", "xyz" )
|
||||
);
|
||||
em.createQuery( cq ).getResultList();
|
||||
|
||||
// Should all fail to compile
|
||||
// cb.arrayReplace( root.<Integer[]>get( "theArray" ), cb.literal( "abc" ), cb.literal( "xyz" ) );
|
||||
// cb.arrayReplace( root.<Integer[]>get( "theArray" ), cb.literal( "abc" ), "xyz" );
|
||||
// cb.arrayReplace( root.<Integer[]>get( "theArray" ), "abc", cb.literal( "xyz" ) );
|
||||
// cb.arrayReplace( root.<Integer[]>get( "theArray" ), "abc", "xyz" );
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderCollection(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.collectionReplace( root.<Collection<String>>get( "theCollection" ), cb.literal( "abc" ), cb.literal( "xyz" ) ),
|
||||
cb.collectionReplace( root.<Collection<String>>get( "theCollection" ), cb.literal( "abc" ), "xyz" ),
|
||||
cb.collectionReplace( root.<Collection<String>>get( "theCollection" ), "abc", cb.literal( "xyz" ) ),
|
||||
cb.collectionReplace( root.get( "theCollection" ), "abc", "xyz" )
|
||||
);
|
||||
em.createQuery( cq ).getResultList();
|
||||
|
||||
// Should all fail to compile
|
||||
// cb.collectionReplace( root.<Collection<Integer>>get( "theCollection" ), cb.literal( "abc" ), cb.literal( "xyz" ) );
|
||||
// cb.collectionReplace( root.<Collection<Integer>>get( "theCollection" ), cb.literal( "abc" ), "xyz" );
|
||||
// cb.collectionReplace( root.<Collection<Integer>>get( "theCollection" ), "abc", cb.literal( "xyz" ) );
|
||||
// cb.collectionReplace( root.<Collection<Integer>>get( "theCollection" ), "abc", "xyz" );
|
||||
} );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,9 +6,13 @@
|
|||
*/
|
||||
package org.hibernate.orm.test.function.array;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.query.criteria.JpaCriteriaQuery;
|
||||
import org.hibernate.query.criteria.JpaRoot;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
|
@ -101,4 +105,50 @@ public class ArraySetTest {
|
|||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderArray(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.arraySet( root.<String[]>get( "theArray" ), cb.literal( 1 ), cb.literal( "xyz" ) ),
|
||||
cb.arraySet( root.get( "theArray" ), cb.literal( 1 ), "xyz" ),
|
||||
cb.arraySet( root.<String[]>get( "theArray" ), 1, cb.literal( "xyz" ) ),
|
||||
cb.arraySet( root.get( "theArray" ), 1, "xyz" )
|
||||
);
|
||||
em.createQuery( cq ).getResultList();
|
||||
|
||||
// Should all fail to compile
|
||||
// cb.arraySet( root.<Integer[]>get( "theArray" ), cb.literal( 1 ), cb.literal( "xyz" ) );
|
||||
// cb.arraySet( root.<Integer[]>get( "theArray" ), cb.literal( 1 ), "xyz" );
|
||||
// cb.arraySet( root.<Integer[]>get( "theArray" ), 1, cb.literal( "xyz" ) );
|
||||
// cb.arraySet( root.<Integer[]>get( "theArray" ), 1, "xyz" );
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderCollection(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.collectionSet( root.<Collection<String>>get( "theCollection" ), cb.literal( 1 ), cb.literal( "xyz" ) ),
|
||||
cb.collectionSet( root.get( "theCollection" ), cb.literal( 1 ), "xyz" ),
|
||||
cb.collectionSet( root.<Collection<String>>get( "theCollection" ), 1, cb.literal( "xyz" ) ),
|
||||
cb.collectionSet( root.get( "theCollection" ), 1, "xyz" )
|
||||
);
|
||||
em.createQuery( cq ).getResultList();
|
||||
|
||||
// Should all fail to compile
|
||||
// cb.collectionSet( root.<Collection<Integer>>get( "theCollection" ), cb.literal( 1 ), cb.literal( "xyz" ) );
|
||||
// cb.collectionSet( root.<Collection<Integer>>get( "theCollection" ), cb.literal( 1 ), "xyz" );
|
||||
// cb.collectionSet( root.<Collection<Integer>>get( "theCollection" ), 1, cb.literal( "xyz" ) );
|
||||
// cb.collectionSet( root.<Collection<Integer>>get( "theCollection" ), 1, "xyz" );
|
||||
} );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,10 +6,14 @@
|
|||
*/
|
||||
package org.hibernate.orm.test.function.array;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.dialect.CockroachDialect;
|
||||
import org.hibernate.query.criteria.JpaCriteriaQuery;
|
||||
import org.hibernate.query.criteria.JpaRoot;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
|
@ -105,4 +109,38 @@ public class ArraySliceTest {
|
|||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderArray(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.arraySlice( root.get( "theArray" ), cb.literal( 1 ), cb.literal( 1 ) ),
|
||||
cb.arraySlice( root.get( "theArray" ), cb.literal( 1 ), 1 ),
|
||||
cb.arraySlice( root.get( "theArray" ), 1, cb.literal( 1 ) ),
|
||||
cb.arraySlice( root.get( "theArray" ), 1, 1 )
|
||||
);
|
||||
em.createQuery( cq ).getResultList();
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderCollection(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.collectionSlice( root.get( "theCollection" ), cb.literal( 1 ), cb.literal( 1 ) ),
|
||||
cb.collectionSlice( root.get( "theCollection" ), cb.literal( 1 ), 1 ),
|
||||
cb.collectionSlice( root.get( "theCollection" ), 1, cb.literal( 1 ) ),
|
||||
cb.collectionSlice( root.get( "theCollection" ), 1, 1 )
|
||||
);
|
||||
em.createQuery( cq ).getResultList();
|
||||
} );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,6 +9,9 @@ package org.hibernate.orm.test.function.array;
|
|||
import java.util.List;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.query.criteria.JpaCriteriaQuery;
|
||||
import org.hibernate.query.criteria.JpaRoot;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
|
@ -21,6 +24,7 @@ import org.junit.jupiter.api.AfterEach;
|
|||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jakarta.persistence.Tuple;
|
||||
import org.assertj.core.api.Assertions;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
@ -68,4 +72,34 @@ public class ArrayToStringTest {
|
|||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderArray(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.arrayToString( root.get( "theArray" ), cb.literal( "," ) ),
|
||||
cb.arrayToString( root.get( "theArray" ), "," )
|
||||
);
|
||||
em.createQuery( cq ).getResultList();
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderCollection(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.collectionToString( root.get( "theCollection" ), cb.literal( "," ) ),
|
||||
cb.collectionToString( root.get( "theCollection" ), "," )
|
||||
);
|
||||
em.createQuery( cq ).getResultList();
|
||||
} );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,9 +7,13 @@
|
|||
package org.hibernate.orm.test.function.array;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.query.criteria.JpaCriteriaQuery;
|
||||
import org.hibernate.query.criteria.JpaRoot;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
|
@ -96,4 +100,36 @@ public class ArrayTrimTest {
|
|||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderArray(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.where( root.get( "id" ).equalTo( 2L ) );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.arrayTrim( root.<String[]>get( "theArray" ), cb.literal( 1 ) ),
|
||||
cb.arrayTrim( root.get( "theArray" ), 1 )
|
||||
);
|
||||
em.createQuery( cq ).getResultList();
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderCollection(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
final NodeBuilder cb = (NodeBuilder) em.getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> cq = cb.createTupleQuery();
|
||||
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
|
||||
cq.where( root.get( "id" ).equalTo( 2L ) );
|
||||
cq.multiselect(
|
||||
root.get( "id" ),
|
||||
cb.collectionTrim( root.<Collection<String>>get( "theCollection" ), cb.literal( 1 ) ),
|
||||
cb.collectionTrim( root.get( "theCollection" ), 1 )
|
||||
);
|
||||
em.createQuery( cq ).getResultList();
|
||||
} );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
package org.hibernate.orm.test.function.array;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
|
@ -19,6 +21,9 @@ public class EntityWithArrays {
|
|||
@Column(name = "the_array")
|
||||
private String[] theArray;
|
||||
|
||||
@Column(name = "the_array", insertable = false, updatable = false)
|
||||
private List<String> theCollection;
|
||||
|
||||
public EntityWithArrays() {
|
||||
}
|
||||
|
||||
|
@ -42,4 +47,12 @@ public class EntityWithArrays {
|
|||
public void setTheArray(String[] theArray) {
|
||||
this.theArray = theArray;
|
||||
}
|
||||
|
||||
public List<String> getTheCollection() {
|
||||
return theCollection;
|
||||
}
|
||||
|
||||
public void setTheCollection(List<String> theCollection) {
|
||||
this.theCollection = theCollection;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue