Skip to content

Commit 3ac4103

Browse files
marko-bekhtayrodiere
authored andcommitted
HHH-19583 Include parameterized info of parameterized type arguments
1 parent a5ed73a commit 3ac4103

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
}
@@ -156,7 +159,7 @@ public void verifyReadWorks(SessionFactoryScope scope) {
156159
public void verifyMergeWorks(SessionFactoryScope scope) {
157160
scope.inTransaction(
158161
(session) -> {
159-
session.merge( new EntityWithJson( 2, null, null, null, null ) );
162+
session.merge( new EntityWithJson( 2, null, null, null, null, null) );
160163
}
161164
);
162165

@@ -169,6 +172,7 @@ public void verifyMergeWorks(SessionFactoryScope scope) {
169172
assertThat( entityWithJson.jsonString, is( nullValue() ) );
170173
assertThat( entityWithJson.jsonNode, is( nullValue() ) );
171174
assertThat( entityWithJson.jsonValue, is( nullValue() ) );
175+
assertThat( entityWithJson.complexMap, is( nullValue() ) );
172176
}
173177
);
174178
}
@@ -271,6 +275,7 @@ public void verifyCriteriaUpdateQueryWorks(SessionFactoryScope scope) {
271275
assertThat( entityWithJson.stringMap, is( newMap ) );
272276
assertThat( entityWithJson.list, is( newList ) );
273277
assertThat( entityWithJson.jsonString.replaceAll( "\\s", "" ), is( newJson ) );
278+
assertThat( entityWithJson.complexMap, is( complexMap ) );
274279
} );
275280
}
276281

@@ -300,6 +305,9 @@ public static class EntityWithJson {
300305
@JdbcTypeCode( SqlTypes.JSON )
301306
private JsonValue jsonValue;
302307

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

@@ -308,12 +316,14 @@ public EntityWithJson(
308316
Map<String, String> stringMap,
309317
Map<StringNode, StringNode> objectMap,
310318
List<StringNode> list,
311-
String jsonString) {
319+
String jsonString,
320+
Map<String, Map<String, List<Set<Long>>>> complexMap) {
312321
this.id = id;
313322
this.stringMap = stringMap;
314323
this.objectMap = objectMap;
315324
this.list = list;
316325
this.jsonString = jsonString;
326+
this.complexMap = complexMap;
317327
}
318328
}
319329

0 commit comments

Comments
 (0)