2424import org .hibernate .boot .model .relational .Exportable ;
2525import org .hibernate .boot .model .relational .Sequence ;
2626import org .hibernate .boot .model .relational .SqlStringGenerationContext ;
27+ import org .hibernate .community .dialect .function .json .SingleStoreJsonArrayAggFunction ;
28+ import org .hibernate .community .dialect .function .json .SingleStoreJsonArrayAppendFunction ;
29+ import org .hibernate .community .dialect .function .json .SingleStoreJsonArrayFunction ;
30+ import org .hibernate .community .dialect .function .json .SingleStoreJsonArrayInsertFunction ;
31+ import org .hibernate .community .dialect .function .json .SingleStoreJsonExistsFunction ;
32+ import org .hibernate .community .dialect .function .json .SingleStoreJsonMergepatchFunction ;
33+ import org .hibernate .community .dialect .function .json .SingleStoreJsonObjectAggFunction ;
34+ import org .hibernate .community .dialect .function .json .SingleStoreJsonObjectFunction ;
35+ import org .hibernate .community .dialect .function .json .SingleStoreJsonQueryFunction ;
36+ import org .hibernate .community .dialect .function .json .SingleStoreJsonRemoveFunction ;
37+ import org .hibernate .community .dialect .function .json .SingleStoreJsonSetFunction ;
38+ import org .hibernate .community .dialect .function .json .SingleStoreJsonValueFunction ;
2739import org .hibernate .dialect .DatabaseVersion ;
2840import org .hibernate .dialect .Dialect ;
2941import org .hibernate .dialect .DmlTargetColumnQualifierSupport ;
6476import org .hibernate .mapping .UniqueKey ;
6577import org .hibernate .metamodel .mapping .EntityMappingType ;
6678import org .hibernate .metamodel .spi .RuntimeModelCreationContext ;
79+ import org .hibernate .query .common .TemporalUnit ;
6780import org .hibernate .query .sqm .CastType ;
6881import org .hibernate .query .sqm .IntervalType ;
69- import org .hibernate .query .common .TemporalUnit ;
7082import org .hibernate .query .sqm .function .SqmFunctionRegistry ;
71- import org .hibernate .query .sqm .mutation .spi .AfterUseAction ;
72- import org .hibernate .query .sqm .mutation .spi .BeforeUseAction ;
7383import org .hibernate .query .sqm .mutation .internal .temptable .LocalTemporaryTableInsertStrategy ;
7484import org .hibernate .query .sqm .mutation .internal .temptable .LocalTemporaryTableMutationStrategy ;
85+ import org .hibernate .query .sqm .mutation .spi .AfterUseAction ;
86+ import org .hibernate .query .sqm .mutation .spi .BeforeUseAction ;
7587import org .hibernate .query .sqm .mutation .spi .SqmMultiTableInsertStrategy ;
7688import org .hibernate .query .sqm .mutation .spi .SqmMultiTableMutationStrategy ;
7789import org .hibernate .query .sqm .produce .function .FunctionParameterType ;
8395import org .hibernate .sql .ast .tree .Statement ;
8496import org .hibernate .sql .exec .spi .JdbcOperation ;
8597import org .hibernate .tool .schema .spi .Exporter ;
86- import org .hibernate .type .BasicType ;
8798import org .hibernate .type .BasicTypeRegistry ;
8899import org .hibernate .type .NullType ;
89100import org .hibernate .type .SqlTypes ;
99110import org .hibernate .type .descriptor .sql .internal .NativeEnumDdlTypeImpl ;
100111import org .hibernate .type .descriptor .sql .internal .NativeOrdinalEnumDdlTypeImpl ;
101112import org .hibernate .type .descriptor .sql .spi .DdlTypeRegistry ;
113+ import org .hibernate .type .spi .TypeConfiguration ;
102114
103115import jakarta .persistence .TemporalType ;
104116
105117import static org .hibernate .exception .spi .TemplatedViolatedConstraintNameExtractor .extractUsingTemplate ;
106- import static org .hibernate .query .sqm .produce .function .FunctionParameterType .ANY ;
107118import static org .hibernate .query .sqm .produce .function .FunctionParameterType .NUMERIC ;
108- import static org .hibernate .query .sqm .produce .function .FunctionParameterType .STRING ;
109119import static org .hibernate .type .SqlTypes .BIGINT ;
110120import static org .hibernate .type .SqlTypes .BINARY ;
111121import static org .hibernate .type .SqlTypes .BIT ;
@@ -503,31 +513,35 @@ protected void registerColumnTypes(TypeContributions typeContributions, ServiceR
503513 castType ( BINARY ),
504514 this
505515 )
506- .withTypeCapacity ( maxTinyLobLen , "tinyblob" )
507- .withTypeCapacity ( maxMediumLobLen , "mediumblob" )
508- .withTypeCapacity ( maxLobLen , "blob" )
509- .build () );
516+ .withTypeCapacity ( maxTinyLobLen , "tinyblob" )
517+ .withTypeCapacity ( maxMediumLobLen , "mediumblob" )
518+ .withTypeCapacity ( maxLobLen , "blob" )
519+ .build () );
510520
511521 ddlTypeRegistry .addDescriptor ( CapacityDependentDdlType .builder (
512522 CLOB ,
513523 columnType ( CLOB ),
514524 castType ( CHAR ),
515525 this
516526 )
517- .withTypeCapacity ( maxTinyLobLen , "tinytext" )
518- .withTypeCapacity ( maxMediumLobLen , "mediumtext" )
519- .withTypeCapacity ( maxLobLen , "text" )
520- .build () );
527+ .withTypeCapacity ( maxTinyLobLen , "tinytext" )
528+ .withTypeCapacity ( maxMediumLobLen , "mediumtext" )
529+ .withTypeCapacity ( maxLobLen , "text" )
530+ .build () );
521531
522532 ddlTypeRegistry .addDescriptor ( CapacityDependentDdlType .builder (
523- NCLOB ,
524- columnType ( NCLOB ),
525- castType ( NCHAR ),
526- this
527- ).withTypeCapacity ( maxTinyLobLen , "tinytext character set utf8" ).withTypeCapacity (
528- maxMediumLobLen ,
529- "mediumtext character set utf8"
530- ).withTypeCapacity ( maxLobLen , "text character set utf8" ).build () );
533+ NCLOB ,
534+ columnType ( NCLOB ),
535+ castType ( NCHAR ),
536+ this
537+ )
538+ .withTypeCapacity (
539+ maxTinyLobLen ,
540+ "tinytext character set utf8"
541+ )
542+ .withTypeCapacity ( maxMediumLobLen , "mediumtext character set utf8" )
543+ .withTypeCapacity ( maxLobLen , "text character set utf8" )
544+ .build () );
531545
532546 ddlTypeRegistry .addDescriptor ( new NativeEnumDdlTypeImpl ( this ) );
533547 ddlTypeRegistry .addDescriptor ( new NativeOrdinalEnumDdlTypeImpl ( this ) );
@@ -585,14 +599,13 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
585599 commonFunctionFactory .inverseDistributionOrderedSetAggregates_windowEmulation ();
586600 commonFunctionFactory .listagg_groupConcat ();
587601 SqmFunctionRegistry functionRegistry = functionContributions .getFunctionRegistry ();
602+ final TypeConfiguration typeConfiguration = functionContributions .getTypeConfiguration ();
588603 BasicTypeRegistry basicTypeRegistry = functionContributions .getTypeConfiguration ().getBasicTypeRegistry ();
589- functionRegistry
590- .namedDescriptorBuilder ( "time" )
604+ functionRegistry .namedDescriptorBuilder ( "time" )
591605 .setExactArgumentCount ( 1 )
592606 .setInvariantType ( basicTypeRegistry .resolve ( StandardBasicTypes .STRING ) )
593607 .register ();
594- functionRegistry
595- .patternDescriptorBuilder ( "median" , "median(?1) over ()" )
608+ functionRegistry .patternDescriptorBuilder ( "median" , "median(?1) over ()" )
596609 .setInvariantType ( basicTypeRegistry .resolve ( StandardBasicTypes .DOUBLE ) )
597610 .setExactArgumentCount ( 1 )
598611 .setParameterTypes ( NUMERIC )
@@ -609,45 +622,18 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
609622 .setParameterTypes ( FunctionParameterType .INTEGER )
610623 .register ();
611624 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" );
625+ functionRegistry .register ( "json_object" , new SingleStoreJsonObjectFunction ( typeConfiguration ) );
626+ functionRegistry .register ( "json_array" , new SingleStoreJsonArrayFunction ( typeConfiguration ) );
627+ functionRegistry .register ( "json_value" , new SingleStoreJsonValueFunction ( typeConfiguration ) );
628+ functionRegistry .register ( "json_exists" , new SingleStoreJsonExistsFunction ( typeConfiguration ) );
629+ functionRegistry .register ( "json_query" , new SingleStoreJsonQueryFunction ( typeConfiguration ) );
630+ functionRegistry .register ( "json_arrayagg" , new SingleStoreJsonArrayAggFunction ( typeConfiguration ) );
631+ functionRegistry .register ( "json_objectagg" , new SingleStoreJsonObjectAggFunction ( typeConfiguration ) );
632+ functionRegistry .register ( "json_set" , new SingleStoreJsonSetFunction ( typeConfiguration ) );
633+ functionRegistry .register ( "json_remove" , new SingleStoreJsonRemoveFunction ( typeConfiguration ) );
634+ functionRegistry .register ( "json_mergepatch" , new SingleStoreJsonMergepatchFunction ( typeConfiguration ) );
635+ functionRegistry .register ( "json_array_append" , new SingleStoreJsonArrayAppendFunction ( typeConfiguration ) );
636+ functionRegistry .register ( "json_array_insert" , new SingleStoreJsonArrayInsertFunction ( typeConfiguration ) );
651637 }
652638
653639
@@ -1252,8 +1238,7 @@ public String getAddForeignKeyConstraintString(
12521238 }
12531239
12541240 @ Override
1255- public String getAddForeignKeyConstraintString (
1256- String constraintName , String foreignKeyDefinition ) {
1241+ public String getAddForeignKeyConstraintString (String constraintName , String foreignKeyDefinition ) {
12571242 throw new UnsupportedOperationException ( "SingleStore does not support foreign keys and referential integrity." );
12581243 }
12591244
0 commit comments