Does Spring Data MongoDB support enums?

vic picture vic · Mar 10, 2015 · Viewed 14.7k times · Source

For Java enum type, I learn that there are two solutions for MongoDB: serialization and using Jackson’s ObjectMapper. Can the MongoRepository work with an enum data type with either of those approaches or I have to write a customized repository?

Answer

Oliver Drotbohm picture Oliver Drotbohm · Mar 11, 2015

Yes, Spring Data MongoDB supports enums. Just use them in your domain model.