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

[DE-539] Spring Data: documented object mapping behavior #476

Merged
merged 5 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Review
  • Loading branch information
Simran-B authored and rashtao committed Jun 21, 2024
commit 3b14d0137037b0d5c0f7e405d974e11094a91876
Original file line number Diff line number Diff line change
Expand Up @@ -190,34 +190,36 @@ Spring Data ArangoDB delegates object mapping, object creation, field and proper
[Spring Data Commons](https://docs.spring.io/spring-data/data-commons/docs/current/reference/html/#mapping.fundamentals).

Methods in `ArangoOperations` try modifying the domain objects accepted as parameters,
updating the properties potentially modified by the server side, if the related fields are mutable. This applies to the
fields annotated with:
updating the properties potentially modified by the server side, if the related fields
are mutable. This applies to the fields annotated with:
- `@ArangoId`
- `@Id`
- `@Rev`

In addition, the methods:
In addition, the following methods also try to update the fields annotated with
`@ComputedValueField`:
- `ArangoOperations#repsert(Object)`
- `ArangoOperations#repsertAll(Iterable<Object>, Class<?>)`
will also try updating the fields annotated with `@ComputedValueField`.

## Object Identity

The most of the methods in `ArangoOperations` and `ArangoRepository` return new entity instances, except:
The most of the methods in `ArangoOperations` and `ArangoRepository` return new
entity instances, except the following:
- `ArangoRepository#save(Object)`
- `ArangoRepository#saveAll(Iterable<Object>)`

These methods return by default the same instance(s) of the domain object(s) accepted as parameter(s) and update the
properties potentially modified by the server side, if the related fields are mutable.
These methods return by default the same instance(s) of the domain object(s)
accepted as parameter(s) and update the properties potentially modified by the
server side, if the related fields are mutable.
This applies to the fields annotated with:
- `@ArangoId`
- `@Id`
- `@Rev`
- `@ComputedValueField`

This behavior can be changed by overriding `ArangoConfiguration#returnOriginalEntities()`, which by default returns
`true`. For example, to return new entity instances from `ArangoRepository#save(Object)` and
`ArangoRepository#saveAll(Iterable<Object>)`:
This behavior can be changed by overriding `ArangoConfiguration#returnOriginalEntities()`,
which by default returns `true`. An example of returning new entity instances from
`ArangoRepository#save(Object)` and `ArangoRepository#saveAll(Iterable<Object>)`:

```java
@Configuration
Expand All @@ -238,7 +240,8 @@ Note that also in this case, input parameters properties are still updated, if m

## Working with immutable objects

Spring Data ArangoDB can work with immutable entity classes, like Java Records, Kotlin data classes and final classes
with immutable properties. In this case, to use `ArangoRepository#save(Object)` and
`ArangoRepository#saveAll(Iterable<Object>)` is required overriding `ArangoConfiguration#returnOriginalEntities()` to
make it return `false`, see [Object Identity](#object-identity).
Spring Data ArangoDB can work with immutable entity classes, like Java Records,
Kotlin data classes and final classes with immutable properties. In this case,
to use `ArangoRepository#save(Object)` and `ArangoRepository#saveAll(Iterable<Object>)`
is required overriding `ArangoConfiguration#returnOriginalEntities()` to make it
return `false`, see [Object Identity](#object-identity).
Original file line number Diff line number Diff line change
Expand Up @@ -190,34 +190,36 @@ Spring Data ArangoDB delegates object mapping, object creation, field and proper
[Spring Data Commons](https://docs.spring.io/spring-data/data-commons/docs/current/reference/html/#mapping.fundamentals).

Methods in `ArangoOperations` try modifying the domain objects accepted as parameters,
updating the properties potentially modified by the server side, if the related fields are mutable. This applies to the
fields annotated with:
updating the properties potentially modified by the server side, if the related fields
are mutable. This applies to the fields annotated with:
- `@ArangoId`
- `@Id`
- `@Rev`

In addition, the methods:
In addition, the following methods also try to update the fields annotated with
`@ComputedValueField`:
- `ArangoOperations#repsert(Object)`
- `ArangoOperations#repsertAll(Iterable<Object>, Class<?>)`
will also try updating the fields annotated with `@ComputedValueField`.

## Object Identity

The most of the methods in `ArangoOperations` and `ArangoRepository` return new entity instances, except:
The most of the methods in `ArangoOperations` and `ArangoRepository` return new
entity instances, except the following:
- `ArangoRepository#save(Object)`
- `ArangoRepository#saveAll(Iterable<Object>)`

These methods return by default the same instance(s) of the domain object(s) accepted as parameter(s) and update the
properties potentially modified by the server side, if the related fields are mutable.
These methods return by default the same instance(s) of the domain object(s)
accepted as parameter(s) and update the properties potentially modified by the
server side, if the related fields are mutable.
This applies to the fields annotated with:
- `@ArangoId`
- `@Id`
- `@Rev`
- `@ComputedValueField`

This behavior can be changed by overriding `ArangoConfiguration#returnOriginalEntities()`, which by default returns
`true`. For example, to return new entity instances from `ArangoRepository#save(Object)` and
`ArangoRepository#saveAll(Iterable<Object>)`:
This behavior can be changed by overriding `ArangoConfiguration#returnOriginalEntities()`,
which by default returns `true`. An example of returning new entity instances from
`ArangoRepository#save(Object)` and `ArangoRepository#saveAll(Iterable<Object>)`:

```java
@Configuration
Expand All @@ -238,7 +240,8 @@ Note that also in this case, input parameters properties are still updated, if m

## Working with immutable objects

Spring Data ArangoDB can work with immutable entity classes, like Java Records, Kotlin data classes and final classes
with immutable properties. In this case, to use `ArangoRepository#save(Object)` and
`ArangoRepository#saveAll(Iterable<Object>)` is required overriding `ArangoConfiguration#returnOriginalEntities()` to
make it return `false`, see [Object Identity](#object-identity).
Spring Data ArangoDB can work with immutable entity classes, like Java Records,
Kotlin data classes and final classes with immutable properties. In this case,
to use `ArangoRepository#save(Object)` and `ArangoRepository#saveAll(Iterable<Object>)`
is required overriding `ArangoConfiguration#returnOriginalEntities()` to make it
return `false`, see [Object Identity](#object-identity).
Original file line number Diff line number Diff line change
Expand Up @@ -190,34 +190,36 @@ Spring Data ArangoDB delegates object mapping, object creation, field and proper
[Spring Data Commons](https://docs.spring.io/spring-data/data-commons/docs/current/reference/html/#mapping.fundamentals).

Methods in `ArangoOperations` try modifying the domain objects accepted as parameters,
updating the properties potentially modified by the server side, if the related fields are mutable. This applies to the
fields annotated with:
updating the properties potentially modified by the server side, if the related fields
are mutable. This applies to the fields annotated with:
- `@ArangoId`
- `@Id`
- `@Rev`

In addition, the methods:
In addition, the following methods also try to update the fields annotated with
`@ComputedValueField`:
- `ArangoOperations#repsert(Object)`
- `ArangoOperations#repsertAll(Iterable<Object>, Class<?>)`
will also try updating the fields annotated with `@ComputedValueField`.

## Object Identity

The most of the methods in `ArangoOperations` and `ArangoRepository` return new entity instances, except:
The most of the methods in `ArangoOperations` and `ArangoRepository` return new
entity instances, except the following:
- `ArangoRepository#save(Object)`
- `ArangoRepository#saveAll(Iterable<Object>)`

These methods return by default the same instance(s) of the domain object(s) accepted as parameter(s) and update the
properties potentially modified by the server side, if the related fields are mutable.
These methods return by default the same instance(s) of the domain object(s)
accepted as parameter(s) and update the properties potentially modified by the
server side, if the related fields are mutable.
This applies to the fields annotated with:
- `@ArangoId`
- `@Id`
- `@Rev`
- `@ComputedValueField`

This behavior can be changed by overriding `ArangoConfiguration#returnOriginalEntities()`, which by default returns
`true`. For example, to return new entity instances from `ArangoRepository#save(Object)` and
`ArangoRepository#saveAll(Iterable<Object>)`:
This behavior can be changed by overriding `ArangoConfiguration#returnOriginalEntities()`,
which by default returns `true`. An example of returning new entity instances from
`ArangoRepository#save(Object)` and `ArangoRepository#saveAll(Iterable<Object>)`:

```java
@Configuration
Expand All @@ -238,7 +240,8 @@ Note that also in this case, input parameters properties are still updated, if m

## Working with immutable objects

Spring Data ArangoDB can work with immutable entity classes, like Java Records, Kotlin data classes and final classes
with immutable properties. In this case, to use `ArangoRepository#save(Object)` and
`ArangoRepository#saveAll(Iterable<Object>)` is required overriding `ArangoConfiguration#returnOriginalEntities()` to
make it return `false`, see [Object Identity](#object-identity).
Spring Data ArangoDB can work with immutable entity classes, like Java Records,
Kotlin data classes and final classes with immutable properties. In this case,
to use `ArangoRepository#save(Object)` and `ArangoRepository#saveAll(Iterable<Object>)`
is required overriding `ArangoConfiguration#returnOriginalEntities()` to make it
return `false`, see [Object Identity](#object-identity).