84
84
import org .hibernate .sql .ast .tree .Statement ;
85
85
import org .hibernate .sql .exec .spi .JdbcOperation ;
86
86
import org .hibernate .tool .schema .spi .Exporter ;
87
+ import org .hibernate .type .BasicType ;
87
88
import org .hibernate .type .BasicTypeRegistry ;
88
89
import org .hibernate .type .NullType ;
89
90
import org .hibernate .type .SqlTypes ;
103
104
import jakarta .persistence .TemporalType ;
104
105
105
106
import static org .hibernate .exception .spi .TemplatedViolatedConstraintNameExtractor .extractUsingTemplate ;
107
+ import static org .hibernate .query .sqm .produce .function .FunctionParameterType .ANY ;
106
108
import static org .hibernate .query .sqm .produce .function .FunctionParameterType .NUMERIC ;
109
+ import static org .hibernate .query .sqm .produce .function .FunctionParameterType .STRING ;
107
110
import static org .hibernate .type .SqlTypes .BIGINT ;
108
111
import static org .hibernate .type .SqlTypes .BINARY ;
109
112
import static org .hibernate .type .SqlTypes .BIT ;
@@ -582,23 +585,19 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
582
585
commonFunctionFactory .hypotheticalOrderedSetAggregates_windowEmulation ();
583
586
commonFunctionFactory .inverseDistributionOrderedSetAggregates_windowEmulation ();
584
587
commonFunctionFactory .listagg_groupConcat ();
585
- functionContributions .getFunctionRegistry ()
588
+ SqmFunctionRegistry functionRegistry = functionContributions .getFunctionRegistry ();
589
+ BasicTypeRegistry basicTypeRegistry = functionContributions .getTypeConfiguration ().getBasicTypeRegistry ();
590
+ functionRegistry
586
591
.namedDescriptorBuilder ( "time" )
587
592
.setExactArgumentCount ( 1 )
588
- .setInvariantType ( functionContributions .getTypeConfiguration ()
589
- .getBasicTypeRegistry ()
590
- .resolve ( StandardBasicTypes .STRING ) )
593
+ .setInvariantType ( basicTypeRegistry .resolve ( StandardBasicTypes .STRING ) )
591
594
.register ();
592
- functionContributions . getFunctionRegistry ()
595
+ functionRegistry
593
596
.patternDescriptorBuilder ( "median" , "median(?1) over ()" )
594
- .setInvariantType ( functionContributions .getTypeConfiguration ()
595
- .getBasicTypeRegistry ()
596
- .resolve ( StandardBasicTypes .DOUBLE ) )
597
+ .setInvariantType ( basicTypeRegistry .resolve ( StandardBasicTypes .DOUBLE ) )
597
598
.setExactArgumentCount ( 1 )
598
599
.setParameterTypes ( NUMERIC )
599
600
.register ();
600
- BasicTypeRegistry basicTypeRegistry = functionContributions .getTypeConfiguration ().getBasicTypeRegistry ();
601
- SqmFunctionRegistry functionRegistry = functionContributions .getFunctionRegistry ();
602
601
functionRegistry .noArgsBuilder ( "localtime" )
603
602
.setInvariantType ( basicTypeRegistry .resolve ( StandardBasicTypes .TIMESTAMP ) )
604
603
.setUseParenthesesWhenNoArgs ( false )
@@ -611,6 +610,45 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
611
610
.setParameterTypes ( FunctionParameterType .INTEGER )
612
611
.register ();
613
612
functionRegistry .registerAlternateKey ( "char" , "chr" );
613
+ BasicType <Boolean > booleanType = basicTypeRegistry .resolve ( StandardBasicTypes .BOOLEAN );
614
+ functionRegistry .namedDescriptorBuilder ( "json_array_contains_string" )
615
+ .setInvariantType ( booleanType )
616
+ .setExactArgumentCount ( 2 )
617
+ .setParameterTypes ( ANY , STRING )
618
+ .register ();
619
+ functionRegistry .registerAlternateKey ( "json_array_contains" , "json_array_contains_string" );
620
+ functionRegistry .namedDescriptorBuilder ( "json_array_contains_json" )
621
+ .setInvariantType ( booleanType )
622
+ .setExactArgumentCount ( 2 )
623
+ .setParameterTypes ( ANY , ANY )
624
+ .register ();
625
+ functionRegistry .namedDescriptorBuilder ( "json_array_contains_double" )
626
+ .setInvariantType ( booleanType )
627
+ .setExactArgumentCount ( 2 )
628
+ .setParameterTypes ( ANY , NUMERIC )
629
+ .register ();
630
+ functionRegistry .namedDescriptorBuilder ( "json_match_any_exists" )
631
+ .setInvariantType ( booleanType )
632
+ .setMinArgumentCount ( 1 )
633
+ .register ();
634
+ functionRegistry .namedDescriptorBuilder ( "json_match_any" )
635
+ .setInvariantType ( booleanType )
636
+ .setMinArgumentCount ( 1 )
637
+ .register ();
638
+ functionRegistry .namedDescriptorBuilder ( "json_extract_string" )
639
+ .setInvariantType ( basicTypeRegistry .resolve ( StandardBasicTypes .STRING ) )
640
+ .setMinArgumentCount ( 1 )
641
+ .register ();
642
+ functionRegistry .namedDescriptorBuilder ( "json_extract_double" )
643
+ .setInvariantType ( basicTypeRegistry .resolve ( StandardBasicTypes .DOUBLE ) )
644
+ .setMinArgumentCount ( 1 )
645
+ .register ();
646
+ functionRegistry .namedDescriptorBuilder ( "json_extract_bigint" )
647
+ .setInvariantType ( basicTypeRegistry .resolve ( StandardBasicTypes .BIG_INTEGER ) )
648
+ .setMinArgumentCount ( 1 )
649
+ .register ();
650
+ functionRegistry .registerAlternateKey ( "json_extract" , "json_extract_string" );
651
+ functionRegistry .registerAlternateKey ( "json_extract_json" , "json_extract_string" );
614
652
}
615
653
616
654
0 commit comments