Skip to content

Commit 79a8d33

Browse files
committed
HHH-18796 Add JSON aggregate support for DB2
1 parent c707bcd commit 79a8d33

File tree

14 files changed

+667
-71
lines changed

14 files changed

+667
-71
lines changed

hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/DB2LegacyDialect.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
439439
functionFactory.jsonArray_db2();
440440
functionFactory.jsonArrayAgg_db2();
441441
functionFactory.jsonObjectAgg_db2();
442-
functionFactory.jsonTable_db2();
442+
functionFactory.jsonTable_db2( getMaximumSeriesSize() );
443443
}
444444
}
445445

@@ -459,7 +459,7 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
459459
functionFactory.xmlagg();
460460
functionFactory.xmltable_db2();
461461

462-
functionFactory.unnest_emulated();
462+
functionFactory.unnest_db2( getMaximumSeriesSize() );
463463
if ( supportsRecursiveCTE() ) {
464464
functionFactory.generateSeries_recursive( getMaximumSeriesSize(), false, true );
465465
}
@@ -1007,7 +1007,9 @@ public <X> ValueExtractor<X> getExtractor(JavaType<X> javaType) {
10071007

10081008
@Override
10091009
public AggregateSupport getAggregateSupport() {
1010-
return DB2AggregateSupport.INSTANCE;
1010+
return getDB2Version().isSameOrAfter( 11 )
1011+
? DB2AggregateSupport.JSON_INSTANCE
1012+
: DB2AggregateSupport.INSTANCE;
10111013
}
10121014

10131015
@Override

hibernate-core/src/main/java/org/hibernate/dialect/DB2Dialect.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
425425
functionFactory.jsonArray_db2();
426426
functionFactory.jsonArrayAgg_db2();
427427
functionFactory.jsonObjectAgg_db2();
428-
functionFactory.jsonTable_db2();
428+
functionFactory.jsonTable_db2( getMaximumSeriesSize() );
429429
}
430430

431431
functionFactory.xmlelement();
@@ -444,7 +444,7 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
444444
functionFactory.xmlagg();
445445
functionFactory.xmltable_db2();
446446

447-
functionFactory.unnest_emulated();
447+
functionFactory.unnest_db2( getMaximumSeriesSize() );
448448
functionFactory.generateSeries_recursive( getMaximumSeriesSize(), false, true );
449449
}
450450

@@ -1081,7 +1081,9 @@ public <X> ValueExtractor<X> getExtractor(JavaType<X> javaType) {
10811081

10821082
@Override
10831083
public AggregateSupport getAggregateSupport() {
1084-
return DB2AggregateSupport.INSTANCE;
1084+
return getDB2Version().isSameOrAfter( 11 )
1085+
? DB2AggregateSupport.JSON_INSTANCE
1086+
: DB2AggregateSupport.INSTANCE;
10851087
}
10861088

10871089
@Override

0 commit comments

Comments
 (0)