File tree Expand file tree Collapse file tree 2 files changed +44
-1
lines changed
main/java/org/springframework/data/redis/hash
test/java/org/springframework/data/redis/mapping Expand file tree Collapse file tree 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) {
177177 return false ;
178178 }
179179
180- if (flatten && type .isTypeOrSubTypeOf (Number .class )) {
180+ if (flatten && ( type .isTypeOrSubTypeOf (Number .class ) || type . isEnumType () )) {
181181 return false ;
182182 }
183183
Original file line number Diff line number Diff line change @@ -203,6 +203,15 @@ void bigDecimalShouldBeTreatedCorrectly() {
203203 assertBackAndForwardMapping (source );
204204 }
205205
206+ @ Test // GH-2979
207+ void enumsShouldBeTreatedCorrectly () {
208+
209+ WithEnumValue source = new WithEnumValue ();
210+ source .value = SpringDataEnum .REDIS ;
211+
212+ assertBackAndForwardMapping (source );
213+ }
214+
206215 public static class WithList {
207216
208217 List <String > strings ;
@@ -452,4 +461,38 @@ public int hashCode() {
452461 return Objects .hash (getValue ());
453462 }
454463 }
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+ }
455498}
You can’t perform that action at this time.
0 commit comments