8000 CRUD Repository save and saveAll should return fetched entity instead of original · Issue #291 · arangodb/spring-data · GitHub
[go: up one dir, main page]

Skip to content

CRUD Repository save and saveAll should return fetched entity instead of original #291

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

Closed
aburmeis opened this issue Oct 25, 2023 · 1 comment · Fixed by #295
Closed
Assignees

Comments

@aburmeis
Copy link
Contributor
aburmeis commented Oct 25, 2023

If you want to use any relations included by annotated members, currently an additional fetch is needed as the original saved entity typically has no proxies for relations or refs.

This is also a very typical behaviour of other spring data implementations. Not sure if this is a bug or an enhancement.

The code involved are the default implementations in SimpleArangoRepository which currently does an explicit return of the original entity instead of returning the REPSERT result in save() and saveAll().

@rashtao
Copy link
Collaborator
rashtao commented Jan 18, 2024

Is there any convention about it in Spring Data NoSQL projects?
AFAICS in Spring Data MongoDB, CrudRepository#save(S): S returns:

  • the same instance as the argument, optionally populated with new values, if the argument is mutable
  • a new instance, if the argument is immutable (e.g. Java record)

@rashtao rashtao self-assigned this Feb 2, 2024
rashtao pushed a commit to aburmeis/spring-data that referenced this issue Feb 2, 2024
rashtao pushed a commit to aburmeis/spring-data that referenced this issue Feb 2, 2024
rashtao added a commit that referenced this issue Feb 6, 2024
* #291 return fetched instead of original entity

* remove some warnings

* #291 make the behaviour customizable, defaulting to the old one

* fixed tests config


5492
* test with java records

* test with immutable entities

* added returnOriginalEntities configuration

---------

Co-authored-by: Michele Rastelli <michele@arangodb.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
0