Skip to content

findAndReplace does not generate Version when null #4536

Closed
@fcappi

Description

@fcappi

Hi,

I have a java class with a version field annotated with @Version

public class BaseDocument {
  @Id private String id;
  @CreatedDate private Instant createdAt;
  @LastModifiedDate private Instant updatedAt;
  @Version private Long version;
}

When using .save() method it automatically generate the version and keep track of it, but if I use findAndReplace with an object where version field is null, it keeps it as null.

I was expecting that findAndReplace would auto generate the version if not set on the object. So is this as design or a bug in this specific method?

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions