Skip to content

Commit 5d666cc

Browse files
committed
DATACOUCH-518 - Update documentation on entities.
1 parent 77fef2e commit 5d666cc

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

src/main/asciidoc/entity.adoc

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,23 @@ include::{spring-data-commons-docs}/object-mapping.adoc[leveloffset=+1]
88
[[basics]]
99
== Documents and Fields
1010

11-
All entities should be annotated with the `@Document` annotation.
11+
All entities should be annotated with the `@Document` annotation, but it is not a requirement.
1212

13-
Also, every field in the entity should be annotated with the `@Field` annotation from the Couchbase SDK. While this is - strictly speaking - optional, it helps to reduce edge cases and clearly shows the intent and design of the entity.
14-
It can also be used to store the field under a different name.
13+
Also, every field in the entity should be annotated with the `@Field` annotation. While this is - strictly speaking -
14+
optional, it helps to reduce edge cases and clearly shows the intent and design of the entity. It can also be used to
15+
store the field under a different name.
1516

16-
There is also a special `@Id` annotation which needs to be always in place.
17-
Best practice is to also name the property `id`.
18-
19-
TIP: Both the Couchbase SDK and Spring Data define their own `@Id` annotation.
20-
Either can be used (the Spring Data one will get priority if both are found on different fields).
17+
There is also a special `@Id` annotation which needs to be always in place. Best practice is to also name the property
18+
`id`.
2119

2220
Here is a very simple `User` entity:
2321

2422
.A simple Document with Fields
2523
====
2624
[source,java]
2725
----
28-
import com.couchbase.client.java.repository.annotation.Id;
29-
import com.couchbase.client.java.repository.annotation.Field;
26+
import org.springframework.data.annotation.Id;
27+
import org.springframework.data.couchbase.core.mapping.Field;
3028
import org.springframework.data.couchbase.core.mapping.Document;
3129
3230
@Document

src/main/asciidoc/migrating.adoc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,19 @@ The new SDK still has an environment that is used to configure it, so you can ov
1818

1919
For more information, see <<couchbase.configuration>>.
2020

21+
[[couchbase.migrating.entities]]
22+
== Entities
23+
How to deal with entities has not changed, although since the SDK now does not ship annotations anymore only Spring-Data related annotations are supported.
24+
25+
Specifically:
26+
27+
- `com.couchbase.client.java.repository.annotation.Id` became `import org.springframework.data.annotation.Id`
28+
- `com.couchbase.client.java.repository.annotation.Field` became `import org.springframework.data.couchbase.core.mapping.Field`
29+
30+
The `org.springframework.data.couchbase.core.mapping.Document` annotation stayed the same.
31+
32+
For more information, see <<couchbase.entity>>.
33+
2134
[[couchbase.migrating.template]]
2235
== Template and ReactiveTemplate
2336

0 commit comments

Comments
 (0)