Q: @Version field is not added to document when using Spring Data & Couchbase I'm trying to create an object in Couchbase with a @Version field.
So I created a class like that ( following this example  about Optimistic Locking 1):
@Document
@Data
@AllArgsConstructor(onConstructor = @__(@PersistenceConstructor))
@RequiredArgsConstructor
@Builder
public class CatLock{

@Id
@GeneratedValue(strategy = GenerationStrategy.UNIQUE)
private String id;

@Version
private long version;

@Field
final private String catName;
}

When saving the document there is no problem:
  CatLock catLock = CatLock.builder()
                    .catName("Oscar")
                    .build();
  catLockRepository.save(catLock);

But when checking the document in the DB, using the Couchbase UI, I see there is no version field in the document (and also there is no id field in it):
{
  "_class": "com.example.CatLock",
  "catName": "Oscar"
}

And when the code gets to the point where we try to read the object:
CatLock inDB = catLockRepository.findCatLockByCatName("Oscar");

We get this error:

Caused by: java.lang.IllegalArgumentException: Parameter version must not be null!

I tried at one point to add version = 1L when creating the object in the first place, but it didn't help: The code passed successfully the catLockRepository.save(catLock) but nothing is saved in the DB.
I also saw that I'm not supposed to touch/alter the version field.
What an I missing here?

A: Seems like the problem was in the annotations of the CatLock class.
I changed
@AllArgsConstructor(onConstructor = @__(@PersistenceConstructor))
to simply
@AllArgsConstructor

And it started to work OK.
