Skip to content

Commit f3cd779

Browse files
marko-bekhtayrodiere
authored andcommitted
HHH-19583 Include parameterized info of parameterized type arguments
1 parent c12147a commit f3cd779

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
@@ -44,6 +44,7 @@
4444
import java.sql.Clob;
4545
import java.util.List;
4646
import java.util.Map;
47+
import java.util.Set;
4748

4849
import static org.hamcrest.MatcherAssert.assertThat;
4950
import static org.hamcrest.Matchers.equalTo;
@@ -81,6 +82,7 @@ public Jackson() {
8182
private final Map<StringNode, StringNode> objectMap;
8283
private final List<StringNode> list;
8384
private final String json;
85+
Map<String, Map<String, List<Set<Long>>>> complexMap;
8486

8587
protected JsonMappingTests(boolean supportsObjectMapKey) {
8688
this.stringMap = Map.of( "name", "ABC" );
@@ -90,13 +92,14 @@ protected JsonMappingTests(boolean supportsObjectMapKey) {
9092
) : null;
9193
this.list = List.of( new StringNode( "ABC" ) );
9294
this.json = "{\"name\":\"abc\"}";
95+
this.complexMap = Map.of( "name", Map.of( "inner", List.of( Set.of( 10L ), Set.of( 20L ) ) ) );
9396
}
9497

9598
@BeforeEach
9699
public void setup(SessionFactoryScope scope) {
97100
scope.inTransaction(
98101
(session) -> {
99-
session.persist( new EntityWithJson( 1, stringMap, objectMap, list, json ) );
102+
session.persist( new EntityWithJson( 1, stringMap, objectMap, list, json, complexMap ) );
100103
}
101104
);
102105
}
@@ -153,7 +156,7 @@ public void verifyReadWorks(SessionFactoryScope scope) {
153156
public void verifyMergeWorks(SessionFactoryScope scope) {
154157
scope.inTransaction(
155158
(session) -> {
156-
session.merge( new EntityWithJson( 2, null, null, null, null ) );
159+
session.merge( new EntityWithJson( 2, null, null, null, null, null) );
157160
}
158161
);
159162

@@ -166,6 +169,7 @@ public void verifyMergeWorks(SessionFactoryScope scope) {
166169
assertThat( entityWithJson.jsonString, is( nullValue() ) );
167170
assertThat( entityWithJson.jsonNode, is( nullValue() ) );
168171
assertThat( entityWithJson.jsonValue, is( nullValue() ) );
172+
assertThat( entityWithJson.complexMap, is( nullValue() ) );
169173
}
170174
);
171175
}
@@ -270,6 +274,7 @@ public void verifyCriteriaUpdateQueryWorks(SessionFactoryScope scope) {
270274
assertThat( entityWithJson.stringMap, is( newMap ) );
271275
assertThat( entityWithJson.list, is( newList ) );
272276
assertThat( entityWithJson.jsonString.replaceAll( "\\s", "" ), is( newJson ) );
277+
assertThat( entityWithJson.complexMap, is( complexMap ) );
273278
} );
274279
}
275280

@@ -299,6 +304,9 @@ public static class EntityWithJson {
299304
@JdbcTypeCode( SqlTypes.JSON )
300305
private JsonValue jsonValue;
301306

307+
@JdbcTypeCode( SqlTypes.JSON )
308+
private Map<String, Map<String, List<Set<Long>>>> complexMap;
309+
302310
public EntityWithJson() {
303311
}
304312

@@ -307,12 +315,14 @@ public EntityWithJson(
307315
Map<String, String> stringMap,
308316
Map<StringNode, StringNode> objectMap,
309317
List<StringNode> list,
310-
String jsonString) {
318+
String jsonString,
319+
Map<String, Map<String, List<Set<Long>>>> complexMap) {
311320
this.id = id;
312321
this.stringMap = stringMap;
313322
this.objectMap = objectMap;
314323
this.list = list;
315324
this.jsonString = jsonString;
325+
this.complexMap = complexMap;
316326
}
317327
}
318328

0 commit comments

Comments
 (0)