|
4 | 4 | */
|
5 | 5 | package org.hibernate.orm.test.function.array;
|
6 | 6 |
|
| 7 | +import java.util.Arrays; |
7 | 8 | import java.util.List;
|
8 | 9 |
|
9 | 10 | import org.hibernate.boot.ResourceStreamLocator;
|
10 | 11 | import org.hibernate.boot.spi.AdditionalMappingContributions;
|
11 | 12 | import org.hibernate.boot.spi.AdditionalMappingContributor;
|
12 | 13 | import org.hibernate.boot.spi.InFlightMetadataCollector;
|
13 | 14 | import org.hibernate.boot.spi.MetadataBuildingContext;
|
| 15 | +import org.hibernate.dialect.PostgreSQLDialect; |
14 | 16 | import org.hibernate.dialect.type.OracleArrayJdbcType;
|
15 | 17 | import org.hibernate.dialect.OracleDialect;
|
16 | 18 | import org.hibernate.dialect.SpannerDialect;
|
17 | 19 | import org.hibernate.engine.jdbc.Size;
|
18 | 20 | import org.hibernate.query.criteria.JpaCriteriaQuery;
|
19 | 21 | import org.hibernate.query.criteria.JpaRoot;
|
20 | 22 | import org.hibernate.query.sqm.NodeBuilder;
|
| 23 | +import org.hibernate.testing.orm.junit.RequiresDialect; |
21 | 24 | import org.hibernate.type.SqlTypes;
|
22 | 25 | import org.hibernate.type.descriptor.java.ArrayJavaType;
|
23 | 26 | import org.hibernate.type.descriptor.java.spi.JavaTypeRegistry;
|
|
35 | 38 | import org.hibernate.testing.orm.junit.SessionFactory;
|
36 | 39 | import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
37 | 40 | import org.hibernate.testing.orm.junit.SkipForDialect;
|
| 41 | +import org.hibernate.testing.orm.junit.Jira; |
38 | 42 | import org.junit.jupiter.api.AfterEach;
|
39 | 43 | import org.junit.jupiter.api.BeforeEach;
|
40 | 44 | import org.junit.jupiter.api.Test;
|
@@ -170,4 +174,21 @@ public void testNonExistingArrayType(SessionFactoryScope scope) {
|
170 | 174 | } );
|
171 | 175 | }
|
172 | 176 |
|
| 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 | + |
173 | 194 | }
|
0 commit comments