Skip to content

Commit ef6fb9c

Browse files
deniswsrosadaschl
authored andcommitted
DATACOUCH-519 - Update migration docs
1 parent 7773a19 commit ef6fb9c

File tree

2 files changed

+93
-5
lines changed

2 files changed

+93
-5
lines changed

src/main/asciidoc/entity.adoc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,12 @@ This is required for N1QL support.
346346
[[version]]
347347
== Optimistic Locking
348348

349-
Couchbase Server does not support multi-document transactions or rollback.
350-
To implement optimistic locking, Couchbase uses a CAS (compare and swap) approach.
351-
When a document is mutated, the CAS value also changes.
349+
350+
In certain situations you may want to ensure that you are not overwriting another users changes when you perform a mutation operation on a document. For this you have three choices: Transactions (since Couchbase 6.5), pessimistic concurrency (locking) or optimistic concurrency.
351+
352+
Optimistic concurrency tends to provide better performance than pessimistic concurrency or transactions, because no actual locks are held on the data and no extra information is stored about the operation (no transaction log).
353+
354+
To implement optimistic locking, Couchbase uses a CAS (compare and swap) approach. When a document is mutated, the CAS value also changes.
352355
The CAS is opaque to the client, the only thing you need to know is that it changes when the content or a meta information changes too.
353356

354357
In other datastores, similar behavior can be achieved through an arbitrary version field with a incrementing counter.

src/main/asciidoc/migrating.adoc

Lines changed: 87 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,15 @@ 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+
=== Spring Boot Version Support
22+
23+
Spring Data Couchbase 4.x requires Spring Boot 2.3.x or higher.
24+
25+
If you are using Spring Boot in your project with Spring Data Couchbase 3.x, you will likely need to upgrade your Spring Boot version as well.
26+
2127
[[couchbase.migrating.entities]]
28+
29+
2230
== Entities
2331
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.
2432

@@ -31,6 +39,14 @@ The `org.springframework.data.couchbase.core.mapping.Document` annotation stayed
3139

3240
For more information, see <<couchbase.entity>>.
3341

42+
43+
[[couchbase.migrating.indexes]]
44+
== Automatic Index Management
45+
46+
Automatic Index Management has been redesigned to allow more flexible indexing. New annotations have been introduced and old ones like `@ViewIndexed`, `@N1qlSecondaryIndexed` and `@N1qlPrimaryIndexed` were removed.
47+
48+
For more information, see <<couchbase.repository.indexing>>.
49+
3450
[[couchbase.migrating.template]]
3551
== Template and ReactiveTemplate
3652

@@ -102,12 +118,81 @@ We tried to unify and align the APIs more closely to the underlying SDK semantic
102118
For more information, see <<couchbase.template>>.
103119

104120
[[couchbase.migrating.repository]]
105-
== Repository queries
121+
== Repositories & Queries
122+
123+
- `org.springframework.data.couchbase.core.query.Query` became `org.springframework.data.couchbase.repository.Query`
124+
- `org.springframework.data.couchbase.repository.ReactiveCouchbaseSortingRepository` has been removed. Consider extending `ReactiveSortingRepository` or `ReactiveCouchbaseRepository`
125+
- `org.springframework.data.couchbase.repository.CouchbasePagingAndSortingRepository` has been removed. Consider extending `PagingAndSortingRepository` or `CouchbaseRepository`
126+
106127

107128
IMPORTANT: Support for views has been removed and N1QL queries are now the first-class citizens for all custom repository methods as well as the built-in ones by default.
108129

109130
The behavior itself has not changed over the previous version on how the query derivation is supposed to work. Should you encounter any queries that worked in the past and now do not work anymore please let us know.
110131

111132
It is possible to override the default scan consistency for N1QL queries through the new `ScanConsistency` annotation.
112133

113-
See <<couchbase.repository>> for more information.
134+
The method `getCouchbaseOperations()` has also been removed. You can still access all methods from the native Java SDK via the class `CouchbaseTemplate` or `Cluster`:
135+
136+
====
137+
[source,java]
138+
----
139+
import org.springframework.beans.factory.annotation.Autowired;
140+
import org.springframework.data.couchbase.core.CouchbaseTemplate;
141+
import org.springframework.stereotype.Service;
142+
import com.couchbase.client.java.Cluster;
143+
144+
@Service
145+
public class MyService {
146+
147+
@Autowired
148+
private CouchbaseTemplate couchbaseTemplate;
149+
150+
@Autowired
151+
private Cluster cluster;
152+
}
153+
----
154+
====
155+
156+
See <<couchbase.repository>> for more information.
157+
158+
159+
== Full Text Search (FTS)
160+
161+
The FTS API has been simplified and now can be accessed via the `Cluster` class:
162+
163+
====
164+
[source,java]
165+
----
166+
import org.springframework.beans.factory.annotation.Autowired;
167+
import org.springframework.stereotype.Service;
168+
import com.couchbase.client.java.Cluster;
169+
import com.couchbase.client.java.search.result.SearchResult;
170+
import com.couchbase.client.java.search.result.SearchRow;
171+
import com.couchbase.client.core.error.CouchbaseException;
172+
173+
@Service
174+
public class MyService {
175+
176+
@Autowired
177+
private Cluster cluster;
178+
179+
public void myMethod() {
180+
try {
181+
final SearchResult result = cluster
182+
.searchQuery("index", SearchQuery.queryString("query"));
183+
184+
for (SearchRow row : result.rows()) {
185+
System.out.println("Found row: " + row);
186+
}
187+
188+
System.out.println("Reported total rows: "
189+
+ result.metaData().metrics().totalRows());
190+
} catch (CouchbaseException ex) {
191+
ex.printStackTrace();
192+
}
193+
}
194+
}
195+
----
196+
====
197+
198+
See link:https://docs.couchbase.com/java-sdk/current/howtos/full-text-searching-with-sdk.html[the FTS Documentation] for more information.

0 commit comments

Comments
 (0)