2525import org .hibernate .boot .model .relational .Exportable ;
2626import org .hibernate .boot .model .relational .Sequence ;
2727import org .hibernate .boot .model .relational .SqlStringGenerationContext ;
28+ import org .hibernate .community .dialect .function .json .SingleStoreJsonArrayAggFunction ;
29+ import org .hibernate .community .dialect .function .json .SingleStoreJsonArrayAppendFunction ;
30+ import org .hibernate .community .dialect .function .json .SingleStoreJsonArrayFunction ;
31+ import org .hibernate .community .dialect .function .json .SingleStoreJsonArrayInsertFunction ;
32+ import org .hibernate .community .dialect .function .json .SingleStoreJsonExistsFunction ;
33+ import org .hibernate .community .dialect .function .json .SingleStoreJsonMergepatchFunction ;
34+ import org .hibernate .community .dialect .function .json .SingleStoreJsonObjectAggFunction ;
35+ import org .hibernate .community .dialect .function .json .SingleStoreJsonObjectFunction ;
36+ import org .hibernate .community .dialect .function .json .SingleStoreJsonQueryFunction ;
37+ import org .hibernate .community .dialect .function .json .SingleStoreJsonRemoveFunction ;
38+ import org .hibernate .community .dialect .function .json .SingleStoreJsonSetFunction ;
39+ import org .hibernate .community .dialect .function .json .SingleStoreJsonValueFunction ;
2840import org .hibernate .dialect .DatabaseVersion ;
2941import org .hibernate .dialect .Dialect ;
3042import org .hibernate .dialect .DmlTargetColumnQualifierSupport ;
6577import org .hibernate .mapping .UniqueKey ;
6678import org .hibernate .metamodel .mapping .EntityMappingType ;
6779import org .hibernate .metamodel .spi .RuntimeModelCreationContext ;
80+ import org .hibernate .query .common .TemporalUnit ;
6881import org .hibernate .query .sqm .CastType ;
6982import org .hibernate .query .sqm .IntervalType ;
70- import org .hibernate .query .common .TemporalUnit ;
7183import org .hibernate .query .sqm .function .SqmFunctionRegistry ;
72- import org .hibernate .query .sqm .mutation .spi .AfterUseAction ;
73- import org .hibernate .query .sqm .mutation .spi .BeforeUseAction ;
7484import org .hibernate .query .sqm .mutation .internal .temptable .LocalTemporaryTableInsertStrategy ;
7585import org .hibernate .query .sqm .mutation .internal .temptable .LocalTemporaryTableMutationStrategy ;
86+ import org .hibernate .query .sqm .mutation .spi .AfterUseAction ;
87+ import org .hibernate .query .sqm .mutation .spi .BeforeUseAction ;
7688import org .hibernate .query .sqm .mutation .spi .SqmMultiTableInsertStrategy ;
7789import org .hibernate .query .sqm .mutation .spi .SqmMultiTableMutationStrategy ;
7890import org .hibernate .query .sqm .produce .function .FunctionParameterType ;
8496import org .hibernate .sql .ast .tree .Statement ;
8597import org .hibernate .sql .exec .spi .JdbcOperation ;
8698import org .hibernate .tool .schema .spi .Exporter ;
87- import org .hibernate .type .BasicType ;
8899import org .hibernate .type .BasicTypeRegistry ;
89100import org .hibernate .type .NullType ;
90101import org .hibernate .type .SqlTypes ;
100111import org .hibernate .type .descriptor .sql .internal .NativeEnumDdlTypeImpl ;
101112import org .hibernate .type .descriptor .sql .internal .NativeOrdinalEnumDdlTypeImpl ;
102113import org .hibernate .type .descriptor .sql .spi .DdlTypeRegistry ;
114+ import org .hibernate .type .spi .TypeConfiguration ;
103115
104116import jakarta .persistence .TemporalType ;
105117
106118import static org .hibernate .exception .spi .TemplatedViolatedConstraintNameExtractor .extractUsingTemplate ;
107- import static org .hibernate .query .sqm .produce .function .FunctionParameterType .ANY ;
108119import static org .hibernate .query .sqm .produce .function .FunctionParameterType .NUMERIC ;
109- import static org .hibernate .query .sqm .produce .function .FunctionParameterType .STRING ;
110120import static org .hibernate .type .SqlTypes .BIGINT ;
111121import static org .hibernate .type .SqlTypes .BINARY ;
112122import static org .hibernate .type .SqlTypes .BIT ;
@@ -504,31 +514,35 @@ protected void registerColumnTypes(TypeContributions typeContributions, ServiceR
504514 castType ( BINARY ),
505515 this
506516 )
507- .withTypeCapacity ( maxTinyLobLen , "tinyblob" )
508- .withTypeCapacity ( maxMediumLobLen , "mediumblob" )
509- .withTypeCapacity ( maxLobLen , "blob" )
510- .build () );
517+ .withTypeCapacity ( maxTinyLobLen , "tinyblob" )
518+ .withTypeCapacity ( maxMediumLobLen , "mediumblob" )
519+ .withTypeCapacity ( maxLobLen , "blob" )
520+ .build () );
511521
512522 ddlTypeRegistry .addDescriptor ( CapacityDependentDdlType .builder (
513523 CLOB ,
514524 columnType ( CLOB ),
515525 castType ( CHAR ),
516526 this
517527 )
518- .withTypeCapacity ( maxTinyLobLen , "tinytext" )
519- .withTypeCapacity ( maxMediumLobLen , "mediumtext" )
520- .withTypeCapacity ( maxLobLen , "text" )
521- .build () );
528+ .withTypeCapacity ( maxTinyLobLen , "tinytext" )
529+ .withTypeCapacity ( maxMediumLobLen , "mediumtext" )
530+ .withTypeCapacity ( maxLobLen , "text" )
531+ .build () );
522532
523533 ddlTypeRegistry .addDescriptor ( CapacityDependentDdlType .builder (
524- NCLOB ,
525- columnType ( NCLOB ),
526- castType ( NCHAR ),
527- this
528- ).withTypeCapacity ( maxTinyLobLen , "tinytext character set utf8" ).withTypeCapacity (
529- maxMediumLobLen ,
530- "mediumtext character set utf8"
531- ).withTypeCapacity ( maxLobLen , "text character set utf8" ).build () );
534+ NCLOB ,
535+ columnType ( NCLOB ),
536+ castType ( NCHAR ),
537+ this
538+ )
539+ .withTypeCapacity (
540+ maxTinyLobLen ,
541+ "tinytext character set utf8"
542+ )
543+ .withTypeCapacity ( maxMediumLobLen , "mediumtext character set utf8" )
544+ .withTypeCapacity ( maxLobLen , "text character set utf8" )
545+ .build () );
532546
533547 ddlTypeRegistry .addDescriptor ( new NativeEnumDdlTypeImpl ( this ) );
534548 ddlTypeRegistry .addDescriptor ( new NativeOrdinalEnumDdlTypeImpl ( this ) );
@@ -586,14 +600,13 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
586600 commonFunctionFactory .inverseDistributionOrderedSetAggregates_windowEmulation ();
587601 commonFunctionFactory .listagg_groupConcat ();
588602 SqmFunctionRegistry functionRegistry = functionContributions .getFunctionRegistry ();
603+ final TypeConfiguration typeConfiguration = functionContributions .getTypeConfiguration ();
589604 BasicTypeRegistry basicTypeRegistry = functionContributions .getTypeConfiguration ().getBasicTypeRegistry ();
590- functionRegistry
591- .namedDescriptorBuilder ( "time" )
605+ functionRegistry .namedDescriptorBuilder ( "time" )
592606 .setExactArgumentCount ( 1 )
593607 .setInvariantType ( basicTypeRegistry .resolve ( StandardBasicTypes .STRING ) )
594608 .register ();
595- functionRegistry
596- .patternDescriptorBuilder ( "median" , "median(?1) over ()" )
609+ functionRegistry .patternDescriptorBuilder ( "median" , "median(?1) over ()" )
597610 .setInvariantType ( basicTypeRegistry .resolve ( StandardBasicTypes .DOUBLE ) )
598611 .setExactArgumentCount ( 1 )
599612 .setParameterTypes ( NUMERIC )
@@ -610,45 +623,18 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
610623 .setParameterTypes ( FunctionParameterType .INTEGER )
611624 .register ();
612625 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" );
626+ functionRegistry .register ( "json_object" , new SingleStoreJsonObjectFunction ( typeConfiguration ) );
627+ functionRegistry .register ( "json_array" , new SingleStoreJsonArrayFunction ( typeConfiguration ) );
628+ functionRegistry .register ( "json_value" , new SingleStoreJsonValueFunction ( typeConfiguration ) );
629+ functionRegistry .register ( "json_exists" , new SingleStoreJsonExistsFunction ( typeConfiguration ) );
630+ functionRegistry .register ( "json_query" , new SingleStoreJsonQueryFunction ( typeConfiguration ) );
631+ functionRegistry .register ( "json_arrayagg" , new SingleStoreJsonArrayAggFunction ( typeConfiguration ) );
632+ functionRegistry .register ( "json_objectagg" , new SingleStoreJsonObjectAggFunction ( typeConfiguration ) );
633+ functionRegistry .register ( "json_set" , new SingleStoreJsonSetFunction ( typeConfiguration ) );
634+ functionRegistry .register ( "json_remove" , new SingleStoreJsonRemoveFunction ( typeConfiguration ) );
635+ functionRegistry .register ( "json_mergepatch" , new SingleStoreJsonMergepatchFunction ( typeConfiguration ) );
636+ functionRegistry .register ( "json_array_append" , new SingleStoreJsonArrayAppendFunction ( typeConfiguration ) );
637+ functionRegistry .register ( "json_array_insert" , new SingleStoreJsonArrayInsertFunction ( typeConfiguration ) );
652638 }
653639
654640
@@ -1253,8 +1239,7 @@ public String getAddForeignKeyConstraintString(
12531239 }
12541240
12551241 @ Override
1256- public String getAddForeignKeyConstraintString (
1257- String constraintName , String foreignKeyDefinition ) {
1242+ public String getAddForeignKeyConstraintString (String constraintName , String foreignKeyDefinition ) {
12581243 throw new UnsupportedOperationException ( "SingleStore does not support foreign keys and referential integrity." );
12591244 }
12601245
0 commit comments