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