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