Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

findAndReplace does not generate Version when null #4536

Closed
fcappi opened this issue Oct 23, 2023 · 1 comment
Closed

findAndReplace does not generate Version when null #4536

fcappi opened this issue Oct 23, 2023 · 1 comment
Assignees
Labels
type: documentation A documentation update

Comments

@fcappi
Copy link

fcappi commented Oct 23, 2023

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?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 23, 2023
@christophstrobl christophstrobl added the for: team-attention An issue we need to discuss as a team to make progress label Oct 24, 2023
@mp911de mp911de added type: documentation A documentation update and removed status: waiting-for-triage An issue we've not yet triaged for: team-attention An issue we need to discuss as a team to make progress labels Nov 6, 2023
@christophstrobl
Copy link
Member

Thank you @fcappi for reaching out.
The behaviour is by design - we'll update the reference documentation to be more precise on what to expect when using @Version.

mp911de added a commit that referenced this issue Nov 13, 2023
Adjust grammar. Mention that we use proxies for PropertyValueConverter registration when using method handles.

Original pull request: #4553
See #4536
mp911de pushed a commit that referenced this issue Nov 13, 2023
mp911de added a commit that referenced this issue Nov 13, 2023
Adjust grammar. Mention that we use proxies for PropertyValueConverter registration when using method handles.

Original pull request: #4553
See #4536
@mp911de mp911de added this to the 4.1.6 (2023.0.6) milestone Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation A documentation update
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants