diff --git a/src/main/asciidoc/entity.adoc b/src/main/asciidoc/entity.adoc index ebbce57d..6e0bdb1d 100644 --- a/src/main/asciidoc/entity.adoc +++ b/src/main/asciidoc/entity.adoc @@ -8,16 +8,14 @@ include::{spring-data-commons-docs}/object-mapping.adoc[leveloffset=+1] [[basics]] == Documents and Fields -All entities should be annotated with the `@Document` annotation. +All entities should be annotated with the `@Document` annotation, but it is not a requirement. -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. -It can also be used to store the field under a different name. +Also, every field in the entity should be annotated with the `@Field` annotation. While this is - strictly speaking - +optional, it helps to reduce edge cases and clearly shows the intent and design of the entity. It can also be used to +store the field under a different name. -There is also a special `@Id` annotation which needs to be always in place. -Best practice is to also name the property `id`. - -TIP: Both the Couchbase SDK and Spring Data define their own `@Id` annotation. -Either can be used (the Spring Data one will get priority if both are found on different fields). +There is also a special `@Id` annotation which needs to be always in place. Best practice is to also name the property +`id`. Here is a very simple `User` entity: @@ -25,8 +23,8 @@ Here is a very simple `User` entity: ==== [source,java] ---- -import com.couchbase.client.java.repository.annotation.Id; -import com.couchbase.client.java.repository.annotation.Field; +import org.springframework.data.annotation.Id; +import org.springframework.data.couchbase.core.mapping.Field; import org.springframework.data.couchbase.core.mapping.Document; @Document diff --git a/src/main/asciidoc/migrating.adoc b/src/main/asciidoc/migrating.adoc index 52ee3403..fe042afc 100644 --- a/src/main/asciidoc/migrating.adoc +++ b/src/main/asciidoc/migrating.adoc @@ -18,6 +18,19 @@ The new SDK still has an environment that is used to configure it, so you can ov For more information, see <>. +[[couchbase.migrating.entities]] +== Entities +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. + +Specifically: + + - `com.couchbase.client.java.repository.annotation.Id` became `import org.springframework.data.annotation.Id` + - `com.couchbase.client.java.repository.annotation.Field` became `import org.springframework.data.couchbase.core.mapping.Field` + +The `org.springframework.data.couchbase.core.mapping.Document` annotation stayed the same. + +For more information, see <>. + [[couchbase.migrating.template]] == Template and ReactiveTemplate