43
43
import java .sql .Clob ;
44
44
import java .util .List ;
45
45
import java .util .Map ;
46
+ import java .util .Set ;
46
47
47
48
import static org .hamcrest .MatcherAssert .assertThat ;
48
49
import static org .hamcrest .Matchers .equalTo ;
@@ -80,6 +81,7 @@ public Jackson() {
80
81
private final Map <StringNode , StringNode > objectMap ;
81
82
private final List <StringNode > list ;
82
83
private final String json ;
84
+ Map <String , Map <String , List <Set <Long >>>> complexMap ;
83
85
84
86
protected JsonMappingTests (boolean supportsObjectMapKey ) {
85
87
this .stringMap = Map .of ( "name" , "ABC" );
@@ -89,13 +91,14 @@ protected JsonMappingTests(boolean supportsObjectMapKey) {
89
91
) : null ;
90
92
this .list = List .of ( new StringNode ( "ABC" ) );
91
93
this .json = "{\" name\" :\" abc\" }" ;
94
+ this .complexMap = Map .of ( "name" , Map .of ( "inner" , List .of ( Set .of ( 10L ), Set .of ( 20L ) ) ) );
92
95
}
93
96
94
97
@ BeforeEach
95
98
public void setup (SessionFactoryScope scope ) {
96
99
scope .inTransaction (
97
100
(session ) -> {
98
- session .persist ( new EntityWithJson ( 1 , stringMap , objectMap , list , json ) );
101
+ session .persist ( new EntityWithJson ( 1 , stringMap , objectMap , list , json , complexMap ) );
99
102
}
100
103
);
101
104
}
@@ -156,7 +159,7 @@ public void verifyReadWorks(SessionFactoryScope scope) {
156
159
public void verifyMergeWorks (SessionFactoryScope scope ) {
157
160
scope .inTransaction (
158
161
(session ) -> {
159
- session .merge ( new EntityWithJson ( 2 , null , null , null , null ) );
162
+ session .merge ( new EntityWithJson ( 2 , null , null , null , null , null ) );
160
163
}
161
164
);
162
165
@@ -169,6 +172,7 @@ public void verifyMergeWorks(SessionFactoryScope scope) {
169
172
assertThat ( entityWithJson .jsonString , is ( nullValue () ) );
170
173
assertThat ( entityWithJson .jsonNode , is ( nullValue () ) );
171
174
assertThat ( entityWithJson .jsonValue , is ( nullValue () ) );
175
+ assertThat ( entityWithJson .complexMap , is ( nullValue () ) );
172
176
}
173
177
);
174
178
}
@@ -271,6 +275,7 @@ public void verifyCriteriaUpdateQueryWorks(SessionFactoryScope scope) {
271
275
assertThat ( entityWithJson .stringMap , is ( newMap ) );
272
276
assertThat ( entityWithJson .list , is ( newList ) );
273
277
assertThat ( entityWithJson .jsonString .replaceAll ( "\\ s" , "" ), is ( newJson ) );
278
+ assertThat ( entityWithJson .complexMap , is ( complexMap ) );
274
279
} );
275
280
}
276
281
@@ -300,6 +305,9 @@ public static class EntityWithJson {
300
305
@ JdbcTypeCode ( SqlTypes .JSON )
301
306
private JsonValue jsonValue ;
302
307
308
+ @ JdbcTypeCode ( SqlTypes .JSON )
309
+ private Map <String , Map <String , List <Set <Long >>>> complexMap ;
310
+
303
311
public EntityWithJson () {
304
312
}
305
313
@@ -308,12 +316,14 @@ public EntityWithJson(
308
316
Map <String , String > stringMap ,
309
317
Map <StringNode , StringNode > objectMap ,
310
318
List <StringNode > list ,
311
- String jsonString ) {
319
+ String jsonString ,
320
+ Map <String , Map <String , List <Set <Long >>>> complexMap ) {
312
321
this .id = id ;
313
322
this .stringMap = stringMap ;
314
323
this .objectMap = objectMap ;
315
324
this .list = list ;
316
325
this .jsonString = jsonString ;
326
+ this .complexMap = complexMap ;
317
327
}
318
328
}
319
329
0 commit comments