4343import java .sql .Clob ;
4444import java .util .List ;
4545import java .util .Map ;
46+ import java .util .Set ;
4647
4748import static org .hamcrest .MatcherAssert .assertThat ;
4849import 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