File tree 2 files changed +44
-1
lines changed
main/java/org/springframework/data/redis/hash
test/java/org/springframework/data/redis/mapping
2 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -177,7 +177,7 @@ public boolean useForType(JavaType type) {
177
177
return false ;
178
178
}
179
179
180
- if (flatten && type .isTypeOrSubTypeOf (Number .class )) {
180
+ if (flatten && ( type .isTypeOrSubTypeOf (Number .class ) || type . isEnumType () )) {
181
181
return false ;
182
182
}
183
183
Original file line number Diff line number Diff line change @@ -203,6 +203,15 @@ void bigDecimalShouldBeTreatedCorrectly() {
203
203
assertBackAndForwardMapping (source );
204
204
}
205
205
206
+ @ Test // GH-2979
207
+ void enumsShouldBeTreatedCorrectly () {
208
+
209
+ WithEnumValue source = new WithEnumValue ();
210
+ source .value = SpringDataEnum .REDIS ;
211
+
212
+ assertBackAndForwardMapping (source );
213
+ }
214
+
206
215
public static class WithList {
207
216
208
217
List <String > strings ;
@@ -452,4 +461,38 @@ public int hashCode() {
452
461
return Objects .hash (getValue ());
453
462
}
454
463
}
464
+
465
+ enum SpringDataEnum {
466
+ COMMONS , REDIS
467
+ }
468
+
469
+ static class WithEnumValue {
470
+
471
+ SpringDataEnum value ;
472
+
473
+ public SpringDataEnum getValue () {
474
+ return value ;
475
+ }
476
+
477
+ public void setValue (SpringDataEnum value ) {
478
+ this .value = value ;
479
+ }
480
+
481
+ @ Override
482
+ public boolean equals (Object o ) {
483
+ if (o == this ) {
484
+ return true ;
485
+ }
486
+ if (o == null || getClass () != o .getClass ()) {
487
+ return false ;
488
+ }
489
+ WithEnumValue that = (WithEnumValue ) o ;
490
+ return value == that .value ;
491
+ }
492
+
493
+ @ Override
494
+ public int hashCode () {
495
+ return Objects .hash (value );
496
+ }
497
+ }
455
498
}
You can’t perform that action at this time.
0 commit comments