Skip to content

Commit 893cdfd

Browse files
committed
HHH-19681 - Add test for issue
Signed-off-by: Jan Schatteman <[email protected]>
1 parent 98cfad5 commit 893cdfd

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

hibernate-core/src/test/java/org/hibernate/orm/test/function/array/ArrayAggregateTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,23 @@
44
*/
55
package org.hibernate.orm.test.function.array;
66

7+
import java.util.Arrays;
78
import java.util.List;
89

910
import org.hibernate.boot.ResourceStreamLocator;
1011
import org.hibernate.boot.spi.AdditionalMappingContributions;
1112
import org.hibernate.boot.spi.AdditionalMappingContributor;
1213
import org.hibernate.boot.spi.InFlightMetadataCollector;
1314
import org.hibernate.boot.spi.MetadataBuildingContext;
15+
import org.hibernate.dialect.PostgreSQLDialect;
1416
import org.hibernate.dialect.type.OracleArrayJdbcType;
1517
import org.hibernate.dialect.OracleDialect;
1618
import org.hibernate.dialect.SpannerDialect;
1719
import org.hibernate.engine.jdbc.Size;
1820
import org.hibernate.query.criteria.JpaCriteriaQuery;
1921
import org.hibernate.query.criteria.JpaRoot;
2022
import org.hibernate.query.sqm.NodeBuilder;
23+
import org.hibernate.testing.orm.junit.RequiresDialect;
2124
import org.hibernate.type.SqlTypes;
2225
import org.hibernate.type.descriptor.java.ArrayJavaType;
2326
import org.hibernate.type.descriptor.java.spi.JavaTypeRegistry;
@@ -35,6 +38,7 @@
3538
import org.hibernate.testing.orm.junit.SessionFactory;
3639
import org.hibernate.testing.orm.junit.SessionFactoryScope;
3740
import org.hibernate.testing.orm.junit.SkipForDialect;
41+
import org.hibernate.testing.orm.junit.Jira;
3842
import org.junit.jupiter.api.AfterEach;
3943
import org.junit.jupiter.api.BeforeEach;
4044
import org.junit.jupiter.api.Test;
@@ -170,4 +174,21 @@ public void testNonExistingArrayType(SessionFactoryScope scope) {
170174
} );
171175
}
172176

177+
@Test
178+
@Jira("https://hibernate.atlassian.net/browse/HHH-19681")
179+
@RequiresDialect(PostgreSQLDialect.class)
180+
public void testJsonBJdbcArray(SessionFactoryScope scope) {
181+
scope.inTransaction( session -> {
182+
String sql = "select groupId, array_agg(json_values) " +
183+
"from (VALUES (1,'[1,2]'::jsonb),(1,'[10,20]'::jsonb)) as row(groupId,json_values) " +
184+
"group by groupId";
185+
186+
List<Object[]> result = session.createNativeQuery(sql, Object[].class).getResultList();
187+
assertEquals(1,result.size());
188+
assertEquals(2, result.get(0).length);
189+
assertEquals( 1,result.get(0)[0] );
190+
assertEquals( "[[1, 2], [10, 20]]", Arrays.toString((String[])result.get(0)[1]) );
191+
} );
192+
}
193+
173194
}

0 commit comments

Comments
 (0)