Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ public static ParameterizedTypeImpl from(ParameterizedTypeDetails typeDetails) {
final int argumentsSize = arguments.size();
final java.lang.reflect.Type[] argumentTypes = new java.lang.reflect.Type[argumentsSize];
for ( int i = 0; i < argumentsSize; i++ ) {
argumentTypes[i] = arguments.get( i ).determineRawClass().toJavaClass();
TypeDetails argument = arguments.get( i );
if ( argument.getTypeKind() == TypeDetails.Kind.PARAMETERIZED_TYPE ) {
argumentTypes[i] = from( argument.asParameterizedType() );
}
else {
argumentTypes[i] = argument.determineRawClass().toJavaClass();
}
}
final TypeVariableScope owner = typeDetails.asParameterizedType().getOwner();
final java.lang.reflect.Type ownerType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import java.sql.Clob;
import java.util.List;
import java.util.Map;
import java.util.Set;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
Expand Down Expand Up @@ -80,6 +81,7 @@ public Jackson() {
private final Map<StringNode, StringNode> objectMap;
private final List<StringNode> list;
private final String json;
Map<String, Map<String, List<Set<Long>>>> complexMap;

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

@BeforeEach
public void setup(SessionFactoryScope scope) {
scope.inTransaction(
(session) -> {
session.persist( new EntityWithJson( 1, stringMap, objectMap, list, json ) );
session.persist( new EntityWithJson( 1, stringMap, objectMap, list, json, complexMap ) );
}
);
}
Expand Down Expand Up @@ -152,7 +155,7 @@ public void verifyReadWorks(SessionFactoryScope scope) {
public void verifyMergeWorks(SessionFactoryScope scope) {
scope.inTransaction(
(session) -> {
session.merge( new EntityWithJson( 2, null, null, null, null ) );
session.merge( new EntityWithJson( 2, null, null, null, null, null) );
}
);

Expand All @@ -165,6 +168,7 @@ public void verifyMergeWorks(SessionFactoryScope scope) {
assertThat( entityWithJson.jsonString, is( nullValue() ) );
assertThat( entityWithJson.jsonNode, is( nullValue() ) );
assertThat( entityWithJson.jsonValue, is( nullValue() ) );
assertThat( entityWithJson.complexMap, is( nullValue() ) );
}
);
}
Expand Down Expand Up @@ -267,6 +271,7 @@ public void verifyCriteriaUpdateQueryWorks(SessionFactoryScope scope) {
assertThat( entityWithJson.stringMap, is( newMap ) );
assertThat( entityWithJson.list, is( newList ) );
assertThat( entityWithJson.jsonString.replaceAll( "\\s", "" ), is( newJson ) );
assertThat( entityWithJson.complexMap, is( complexMap ) );
} );
}

Expand Down Expand Up @@ -296,6 +301,9 @@ public static class EntityWithJson {
@JdbcTypeCode( SqlTypes.JSON )
private JsonValue jsonValue;

@JdbcTypeCode( SqlTypes.JSON )
private Map<String, Map<String, List<Set<Long>>>> complexMap;

public EntityWithJson() {
}

Expand All @@ -304,12 +312,14 @@ public EntityWithJson(
Map<String, String> stringMap,
Map<StringNode, StringNode> objectMap,
List<StringNode> list,
String jsonString) {
String jsonString,
Map<String, Map<String, List<Set<Long>>>> complexMap) {
this.id = id;
this.stringMap = stringMap;
this.objectMap = objectMap;
this.list = list;
this.jsonString = jsonString;
this.complexMap = complexMap;
}
}

Expand Down