Spring Data Couchbase CouchbaseRepository Storage and Retrieval Bug?

I’m using Sping Data Couchbase with Springboot 2.3.1.RELEASE and Couchbase Server 6.5.1.

I discovered an issue when persisting an object with CouchbaseRepository.save(). I have an Entity as shown below (shortened for emphasis):

@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Document
public class Exam implements Serializable {
      @Id
      private String id;
      private SimpleEntry<String, String> examiner;
      @Field
      private List<SimpleEntry<String, Integer>> papers;
      @Field
      private List<SimpleEntry<String, Integer>> questionsToAnswer;

      public void addQuestionsToAnswer(String paperTitle, int questionCount){
        if( questionsToAnswer == null )
            questionsToAnswer = new ArrayList<>();
        questionsToAnswer.add(new SimpleEntry<>(paperTitle, questionCount));
      }
}

The class uses another class SimpleEntry which is just a replica of Map.Entry:

public class SimpleEntry<K, V> implements Map.Entry<K, V>, Serializable {
    private K key;
    private V value;

    public SimpleEntry(){}

    public SimpleEntry(K key, V value) {
        this.key = key;
        this.value = value;
    }

    @Override
    public K getKey() {
        return key;
    }

    @Override
    public V getValue() {
        return value;
    }

    @Override
    public V setValue(V value) {
        V old = this.value;
        this.value = value;
        return old;
    }

    public void setKey(K key) {
        this.key = key;
    }
}

When saving for the examiner field seems to save ok (not according to the docs) and produces the following when inspected using the admin console:

{
 ...
 "examiner": {
    "content": {
      "value": "user@example.com",
      "key": "Test User"
    },
    "id": null,
    "expiration": 0
  },
 ...
}

However, on retrieval, it returns null for both the key and the value.

Also, for the other two fields, this is what I see from the inspection which failed to even initialize cause its not even an array:

{
 ...
 "questionsToAnswer": {
    "empty": false
  },
  "papers": {
    "empty": false
  },
 ...
}

What could be the issue and what might be the solution? I have used this with Mongodb and it works perfectly. I’m trying to move to couchbase and that’s when I started noticing these errors.

I appreciate any help I can get. Thanks.

I found the issue here - https://jira.spring.io/projects/DATACOUCH/issues/DATACOUCH-560?filter=allissues

Honestly, this has been a surprisingly challeging process.

@ominibyte I’m sorry to hear you are having a challenging time to upgrade. As you can see the issue is planned for the next bugfix release, we are actively working on fixing the issues and papercuts found since 4.0.0.

It is a bit of a challenging situation, because we had to bump the SDK when going from 2 to 3 and spring boot, through picking up the release train, now has it as the default for 2.3.x. We are more than eager to help you get over any other issues you find or things that are not as clear as they should be.