Skip to content

Commit 54dedd1

Browse files
committed
HHH-19583 Include parameterized info of parameterized type arguments
1 parent 63289fb commit 54dedd1

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

hibernate-core/src/main/java/org/hibernate/type/internal/ParameterizedTypeImpl.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,13 @@ public static ParameterizedTypeImpl from(ParameterizedTypeDetails typeDetails) {
3434
final int argumentsSize = arguments.size();
3535
final java.lang.reflect.Type[] argumentTypes = new java.lang.reflect.Type[argumentsSize];
3636
for ( int i = 0; i < argumentsSize; i++ ) {
37-
argumentTypes[i] = arguments.get( i ).determineRawClass().toJavaClass();
37+
TypeDetails argument = arguments.get( i );
38+
if ( argument.getTypeKind() == TypeDetails.Kind.PARAMETERIZED_TYPE ) {
39+
argumentTypes[i] = from( argument.asParameterizedType() );
40+
}
41+
else {
42+
argumentTypes[i] = argument.determineRawClass().toJavaClass();
43+
}
3844
}
3945
final TypeVariableScope owner = typeDetails.asParameterizedType().getOwner();
4046
final java.lang.reflect.Type ownerType;

hibernate-core/src/test/java/org/hibernate/orm/test/mapping/basic/JsonMappingTests.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import java.sql.Clob;
4444
import java.util.List;
4545
import java.util.Map;
46+
import java.util.Set;
4647

4748
import static org.hamcrest.MatcherAssert.assertThat;
4849
import static org.hamcrest.Matchers.equalTo;
@@ -80,6 +81,7 @@ public Jackson() {
8081
private final Map<StringNode, StringNode> objectMap;
8182
private final List<StringNode> list;
8283
private final String json;
84+
Map<String, Map<String, List<Set<Long>>>> complexMap;
8385

8486
protected JsonMappingTests(boolean supportsObjectMapKey) {
8587
this.stringMap = Map.of( "name", "ABC" );
@@ -89,13 +91,14 @@ protected JsonMappingTests(boolean supportsObjectMapKey) {
8991
) : null;
9092
this.list = List.of( new StringNode( "ABC" ) );
9193
this.json = "{\"name\":\"abc\"}";
94+
this.complexMap = Map.of( "name", Map.of( "inner", List.of( Set.of( 10L ), Set.of( 20L ) ) ) );
9295
}
9396

9497
@BeforeEach
9598
public void setup(SessionFactoryScope scope) {
9699
scope.inTransaction(
97100
(session) -> {
98-
session.persist( new EntityWithJson( 1, stringMap, objectMap, list, json ) );
101+
session.persist( new EntityWithJson( 1, stringMap, objectMap, list, json, complexMap ) );
99102
}
100103
);
101104
}
@@ -152,7 +155,7 @@ public void verifyReadWorks(SessionFactoryScope scope) {
152155
public void verifyMergeWorks(SessionFactoryScope scope) {
153156
scope.inTransaction(
154157
(session) -> {
155-
session.merge( new EntityWithJson( 2, null, null, null, null ) );
158+
session.merge( new EntityWithJson( 2, null, null, null, null, null) );
156159
}
157160
);
158161

@@ -165,6 +168,7 @@ public void verifyMergeWorks(SessionFactoryScope scope) {
165168
assertThat( entityWithJson.jsonString, is( nullValue() ) );
166169
assertThat( entityWithJson.jsonNode, is( nullValue() ) );
167170
assertThat( entityWithJson.jsonValue, is( nullValue() ) );
171+
assertThat( entityWithJson.complexMap, is( nullValue() ) );
168172
}
169173
);
170174
}
@@ -267,6 +271,7 @@ public void verifyCriteriaUpdateQueryWorks(SessionFactoryScope scope) {
267271
assertThat( entityWithJson.stringMap, is( newMap ) );
268272
assertThat( entityWithJson.list, is( newList ) );
269273
assertThat( entityWithJson.jsonString.replaceAll( "\\s", "" ), is( newJson ) );
274+
assertThat( entityWithJson.complexMap, is( complexMap ) );
270275
} );
271276
}
272277

@@ -296,6 +301,9 @@ public static class EntityWithJson {
296301
@JdbcTypeCode( SqlTypes.JSON )
297302
private JsonValue jsonValue;
298303

304+
@JdbcTypeCode( SqlTypes.JSON )
305+
private Map<String, Map<String, List<Set<Long>>>> complexMap;
306+
299307
public EntityWithJson() {
300308
}
301309

@@ -304,12 +312,14 @@ public EntityWithJson(
304312
Map<String, String> stringMap,
305313
Map<StringNode, StringNode> objectMap,
306314
List<StringNode> list,
307-
String jsonString) {
315+
String jsonString,
316+
Map<String, Map<String, List<Set<Long>>>> complexMap) {
308317
this.id = id;
309318
this.stringMap = stringMap;
310319
this.objectMap = objectMap;
311320
this.list = list;
312321
this.jsonString = jsonString;
322+
this.complexMap = complexMap;
313323
}
314324
}
315325

0 commit comments

Comments
 (0)