Saving enum by name in couchbase

I am working on spring data couchbase application.In oracle its saving the enum with name but in couchbase its value. I want to save enum name in couchbase instead of its value. But i dont want to change this below existing code. Is there any way to do that? And the enum is not a direct field in document.

public enum Foo {
    Moon("Night"),
    Star("Night"),
    Sun("Day");

    private String value;
    Foo(String value) {
        this.value = value;
    }

    public String getValue() {
        return value;
    }

    @Override
    public String toString() {
        return this.value;
    }
public class Universe{
Map<Foo, <List<List<Cone>>> bar;
}

Couchbase entity class is using

private List<Universe> universe;
Class Universe has hashcode implementation.

Hi priya,
I think you could use a custom converter from Foo to String and vice-versa for this purpose: Spring Data Couchbase - Reference Documentation

1 Like