Skip to content

Commit cf3677c

Browse files
committed
HHH-17355 Add array_positions and array_positions_list to NodeBuilder
1 parent 22819e6 commit cf3677c

File tree

2 files changed

+272
-0
lines changed

2 files changed

+272
-0
lines changed

hibernate-core/src/main/java/org/hibernate/query/sqm/NodeBuilder.java

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,62 @@ <T> JpaExpression<T[]> arrayAgg(
735735
*/
736736
<T> SqmExpression<T[]> arrayFill(T element, Integer elementCount);
737737

738+
/**
739+
* Determines all 1-based positions of an element in an array.
740+
*
741+
* @since 6.4
742+
*/
743+
<T> SqmExpression<int[]> arrayPositions(SqmExpression<T[]> arrayExpression, SqmExpression<T> elementExpression);
744+
745+
/**
746+
* Determines all 1-based positions of an element in an array.
747+
*
748+
* @since 6.4
749+
*/
750+
<T> SqmExpression<int[]> arrayPositions(SqmExpression<T[]> arrayExpression, T element);
751+
752+
/**
753+
* Determines all 1-based positions of an element in an array.
754+
*
755+
* @since 6.4
756+
*/
757+
<T> SqmExpression<int[]> arrayPositions(T[] array, SqmExpression<T> elementExpression);
758+
759+
/**
760+
* Determines all 1-based positions of an element in an array.
761+
*
762+
* @since 6.4
763+
*/
764+
<T> SqmExpression<int[]> arrayPositions(T[] array, T element);
765+
766+
/**
767+
* Determines all 1-based positions of an element in an array.
768+
*
769+
* @since 6.4
770+
*/
771+
<T> SqmExpression<List<Integer>> arrayPositionsList(SqmExpression<T[]> arrayExpression, SqmExpression<T> elementExpression);
772+
773+
/**
774+
* Determines all 1-based positions of an element in an array.
775+
*
776+
* @since 6.4
777+
*/
778+
<T> SqmExpression<List<Integer>> arrayPositionsList(SqmExpression<T[]> arrayExpression, T element);
779+
780+
/**
781+
* Determines all 1-based positions of an element in an array.
782+
*
783+
* @since 6.4
784+
*/
785+
<T> SqmExpression<List<Integer>> arrayPositionsList(T[] array, SqmExpression<T> elementExpression);
786+
787+
/**
788+
* Determines all 1-based positions of an element in an array.
789+
*
790+
* @since 6.4
791+
*/
792+
<T> SqmExpression<List<Integer>> arrayPositionsList(T[] array, T element);
793+
738794
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
739795
// Array functions for collection types
740796

@@ -1333,6 +1389,62 @@ <T> JpaExpression<T[]> arrayAgg(
13331389
*/
13341390
<T> SqmExpression<Collection<T>> collectionFill(T element, Integer elementCount);
13351391

1392+
/**
1393+
* Determines all 1-based positions of an element in a basic collection.
1394+
*
1395+
* @since 6.4
1396+
*/
1397+
<T> SqmExpression<int[]> collectionPositions(SqmExpression<? extends Collection<? super T>> collectionExpression, SqmExpression<T> elementExpression);
1398+
1399+
/**
1400+
* Determines all 1-based positions of an element in a basic collection.
1401+
*
1402+
* @since 6.4
1403+
*/
1404+
<T> SqmExpression<int[]> collectionPositions(SqmExpression<? extends Collection<? super T>> collectionExpression, T element);
1405+
1406+
/**
1407+
* Determines all 1-based positions of an element in a basic collection.
1408+
*
1409+
* @since 6.4
1410+
*/
1411+
<T> SqmExpression<int[]> collectionPositions(Collection<? super T> collection, SqmExpression<T> elementExpression);
1412+
1413+
/**
1414+
* Determines all 1-based positions of an element in a basic collection.
1415+
*
1416+
* @since 6.4
1417+
*/
1418+
<T> SqmExpression<int[]> collectionPositions(Collection<? super T> collection, T element);
1419+
1420+
/**
1421+
* Determines all 1-based positions of an element in a basic collection.
1422+
*
1423+
* @since 6.4
1424+
*/
1425+
<T> SqmExpression<List<Integer>> collectionPositionsList(SqmExpression<? extends Collection<? super T>> collectionExpression, SqmExpression<T> elementExpression);
1426+
1427+
/**
1428+
* Determines all 1-based positions of an element in a basic collection.
1429+
*
1430+
* @since 6.4
1431+
*/
1432+
<T> SqmExpression<List<Integer>> collectionPositionsList(SqmExpression<? extends Collection<? super T>> collectionExpression, T element);
1433+
1434+
/**
1435+
* Determines all 1-based positions of an element in a basic collection.
1436+
*
1437+
* @since 6.4
1438+
*/
1439+
<T> SqmExpression<List<Integer>> collectionPositionsList(Collection<? super T> collection, SqmExpression<T> elementExpression);
1440+
1441+
/**
1442+
* Determines all 1-based positions of an element in a basic collection.
1443+
*
1444+
* @since 6.4
1445+
*/
1446+
<T> SqmExpression<List<Integer>> collectionPositionsList(Collection<? super T> collection, T element);
1447+
13361448
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13371449
// Covariant overrides
13381450

hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SqmCriteriaNodeBuilder.java

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3685,6 +3685,82 @@ public <T> SqmExpression<Integer> arrayPosition(
36853685
);
36863686
}
36873687

3688+
@Override
3689+
public <T> SqmExpression<int[]> arrayPositions(
3690+
SqmExpression<T[]> arrayExpression,
3691+
SqmExpression<T> elementExpression) {
3692+
return getFunctionDescriptor( "array_positions" ).generateSqmExpression(
3693+
asList( arrayExpression, elementExpression ),
3694+
null,
3695+
queryEngine
3696+
);
3697+
}
3698+
3699+
@Override
3700+
public <T> SqmExpression<int[]> arrayPositions(SqmExpression<T[]> arrayExpression, T element) {
3701+
return getFunctionDescriptor( "array_positions" ).generateSqmExpression(
3702+
asList( arrayExpression, value( element ) ),
3703+
null,
3704+
queryEngine
3705+
);
3706+
}
3707+
3708+
@Override
3709+
public <T> SqmExpression<int[]> arrayPositions(T[] array, SqmExpression<T> elementExpression) {
3710+
return getFunctionDescriptor( "array_positions" ).generateSqmExpression(
3711+
asList( value( array ), elementExpression ),
3712+
null,
3713+
queryEngine
3714+
);
3715+
}
3716+
3717+
@Override
3718+
public <T> SqmExpression<int[]> arrayPositions(T[] array, T element) {
3719+
return getFunctionDescriptor( "array_positions" ).generateSqmExpression(
3720+
asList( value( array ), value( element ) ),
3721+
null,
3722+
queryEngine
3723+
);
3724+
}
3725+
3726+
@Override
3727+
public <T> SqmExpression<List<Integer>> arrayPositionsList(
3728+
SqmExpression<T[]> arrayExpression,
3729+
SqmExpression<T> elementExpression) {
3730+
return getFunctionDescriptor( "array_positions_list" ).generateSqmExpression(
3731+
asList( arrayExpression, elementExpression ),
3732+
null,
3733+
queryEngine
3734+
);
3735+
}
3736+
3737+
@Override
3738+
public <T> SqmExpression<List<Integer>> arrayPositionsList(SqmExpression<T[]> arrayExpression, T element) {
3739+
return getFunctionDescriptor( "array_positions_list" ).generateSqmExpression(
3740+
asList( arrayExpression, value( element ) ),
3741+
null,
3742+
queryEngine
3743+
);
3744+
}
3745+
3746+
@Override
3747+
public <T> SqmExpression<List<Integer>> arrayPositionsList(T[] array, SqmExpression<T> elementExpression) {
3748+
return getFunctionDescriptor( "array_positions_list" ).generateSqmExpression(
3749+
asList( value( array ), elementExpression ),
3750+
null,
3751+
queryEngine
3752+
);
3753+
}
3754+
3755+
@Override
3756+
public <T> SqmExpression<List<Integer>> arrayPositionsList(T[] array, T element) {
3757+
return getFunctionDescriptor( "array_positions_list" ).generateSqmExpression(
3758+
asList( value( array ), value( element ) ),
3759+
null,
3760+
queryEngine
3761+
);
3762+
}
3763+
36883764
@Override
36893765
public <T> SqmExpression<Integer> arrayLength(SqmExpression<T[]> arrayExpression) {
36903766
return getFunctionDescriptor( "array_length" ).generateSqmExpression(
@@ -5384,4 +5460,88 @@ public <T> SqmExpression<Collection<T>> collectionFill(T element, Integer elemen
53845460
queryEngine
53855461
);
53865462
}
5463+
5464+
@Override
5465+
public <T> SqmExpression<int[]> collectionPositions(
5466+
SqmExpression<? extends Collection<? super T>> collectionExpression,
5467+
SqmExpression<T> elementExpression) {
5468+
return getFunctionDescriptor( "array_positions" ).generateSqmExpression(
5469+
asList( collectionExpression, elementExpression ),
5470+
null,
5471+
queryEngine
5472+
);
5473+
}
5474+
5475+
@Override
5476+
public <T> SqmExpression<int[]> collectionPositions(
5477+
SqmExpression<? extends Collection<? super T>> collectionExpression,
5478+
T element) {
5479+
return getFunctionDescriptor( "array_positions" ).generateSqmExpression(
5480+
asList( collectionExpression, value( element ) ),
5481+
null,
5482+
queryEngine
5483+
);
5484+
}
5485+
5486+
@Override
5487+
public <T> SqmExpression<int[]> collectionPositions(
5488+
Collection<? super T> collection,
5489+
SqmExpression<T> elementExpression) {
5490+
return getFunctionDescriptor( "array_positions" ).generateSqmExpression(
5491+
asList( value( collection ), elementExpression ),
5492+
null,
5493+
queryEngine
5494+
);
5495+
}
5496+
5497+
@Override
5498+
public <T> SqmExpression<int[]> collectionPositions(Collection<? super T> collection, T element) {
5499+
return getFunctionDescriptor( "array_positions" ).generateSqmExpression(
5500+
asList( value( collection ), value( element ) ),
5501+
null,
5502+
queryEngine
5503+
);
5504+
}
5505+
5506+
@Override
5507+
public <T> SqmExpression<List<Integer>> collectionPositionsList(
5508+
SqmExpression<? extends Collection<? super T>> collectionExpression,
5509+
SqmExpression<T> elementExpression) {
5510+
return getFunctionDescriptor( "array_positions_list" ).generateSqmExpression(
5511+
asList( collectionExpression, elementExpression ),
5512+
null,
5513+
queryEngine
5514+
);
5515+
}
5516+
5517+
@Override
5518+
public <T> SqmExpression<List<Integer>> collectionPositionsList(
5519+
SqmExpression<? extends Collection<? super T>> collectionExpression,
5520+
T element) {
5521+
return getFunctionDescriptor( "array_positions_list" ).generateSqmExpression(
5522+
asList( collectionExpression, value( element ) ),
5523+
null,
5524+
queryEngine
5525+
);
5526+
}
5527+
5528+
@Override
5529+
public <T> SqmExpression<List<Integer>> collectionPositionsList(
5530+
Collection<? super T> collection,
5531+
SqmExpression<T> elementExpression) {
5532+
return getFunctionDescriptor( "array_positions_list" ).generateSqmExpression(
5533+
asList( value( collection ), elementExpression ),
5534+
null,
5535+
queryEngine
5536+
);
5537+
}
5538+
5539+
@Override
5540+
public <T> SqmExpression<List<Integer>> collectionPositionsList(Collection<? super T> collection, T element) {
5541+
return getFunctionDescriptor( "array_positions_list" ).generateSqmExpression(
5542+
asList( value( collection ), value( element ) ),
5543+
null,
5544+
queryEngine
5545+
);
5546+
}
53875547
}

0 commit comments

Comments
 (0)