DATACOUCH-519 - Update migration docs
This commit is contained in:
committed by
Michael Nitschinger
parent
7773a19e42
commit
ef6fb9c43b
@@ -346,9 +346,12 @@ This is required for N1QL support.
|
||||
[[version]]
|
||||
== Optimistic Locking
|
||||
|
||||
Couchbase Server does not support multi-document transactions or rollback.
|
||||
To implement optimistic locking, Couchbase uses a CAS (compare and swap) approach.
|
||||
When a document is mutated, the CAS value also changes.
|
||||
|
||||
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.
|
||||
|
||||
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).
|
||||
|
||||
To implement optimistic locking, Couchbase uses a CAS (compare and swap) approach. When a document is mutated, the CAS value also changes.
|
||||
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.
|
||||
|
||||
In other datastores, similar behavior can be achieved through an arbitrary version field with a incrementing counter.
|
||||
|
||||
@@ -18,7 +18,15 @@ The new SDK still has an environment that is used to configure it, so you can ov
|
||||
|
||||
For more information, see <<couchbase.configuration>>.
|
||||
|
||||
=== Spring Boot Version Support
|
||||
|
||||
Spring Data Couchbase 4.x requires Spring Boot 2.3.x or higher.
|
||||
|
||||
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.
|
||||
|
||||
[[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.
|
||||
|
||||
@@ -31,6 +39,14 @@ The `org.springframework.data.couchbase.core.mapping.Document` annotation stayed
|
||||
|
||||
For more information, see <<couchbase.entity>>.
|
||||
|
||||
|
||||
[[couchbase.migrating.indexes]]
|
||||
== Automatic Index Management
|
||||
|
||||
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.
|
||||
|
||||
For more information, see <<couchbase.repository.indexing>>.
|
||||
|
||||
[[couchbase.migrating.template]]
|
||||
== Template and ReactiveTemplate
|
||||
|
||||
@@ -102,7 +118,12 @@ We tried to unify and align the APIs more closely to the underlying SDK semantic
|
||||
For more information, see <<couchbase.template>>.
|
||||
|
||||
[[couchbase.migrating.repository]]
|
||||
== Repository queries
|
||||
== Repositories & Queries
|
||||
|
||||
- `org.springframework.data.couchbase.core.query.Query` became `org.springframework.data.couchbase.repository.Query`
|
||||
- `org.springframework.data.couchbase.repository.ReactiveCouchbaseSortingRepository` has been removed. Consider extending `ReactiveSortingRepository` or `ReactiveCouchbaseRepository`
|
||||
- `org.springframework.data.couchbase.repository.CouchbasePagingAndSortingRepository` has been removed. Consider extending `PagingAndSortingRepository` or `CouchbaseRepository`
|
||||
|
||||
|
||||
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.
|
||||
|
||||
@@ -110,4 +131,68 @@ The behavior itself has not changed over the previous version on how the query d
|
||||
|
||||
It is possible to override the default scan consistency for N1QL queries through the new `ScanConsistency` annotation.
|
||||
|
||||
See <<couchbase.repository>> for more information.
|
||||
The method `getCouchbaseOperations()` has also been removed. You can still access all methods from the native Java SDK via the class `CouchbaseTemplate` or `Cluster`:
|
||||
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.couchbase.core.CouchbaseTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.couchbase.client.java.Cluster;
|
||||
|
||||
@Service
|
||||
public class MyService {
|
||||
|
||||
@Autowired
|
||||
private CouchbaseTemplate couchbaseTemplate;
|
||||
|
||||
@Autowired
|
||||
private Cluster cluster;
|
||||
}
|
||||
----
|
||||
====
|
||||
|
||||
See <<couchbase.repository>> for more information.
|
||||
|
||||
|
||||
== Full Text Search (FTS)
|
||||
|
||||
The FTS API has been simplified and now can be accessed via the `Cluster` class:
|
||||
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.couchbase.client.java.Cluster;
|
||||
import com.couchbase.client.java.search.result.SearchResult;
|
||||
import com.couchbase.client.java.search.result.SearchRow;
|
||||
import com.couchbase.client.core.error.CouchbaseException;
|
||||
|
||||
@Service
|
||||
public class MyService {
|
||||
|
||||
@Autowired
|
||||
private Cluster cluster;
|
||||
|
||||
public void myMethod() {
|
||||
try {
|
||||
final SearchResult result = cluster
|
||||
.searchQuery("index", SearchQuery.queryString("query"));
|
||||
|
||||
for (SearchRow row : result.rows()) {
|
||||
System.out.println("Found row: " + row);
|
||||
}
|
||||
|
||||
System.out.println("Reported total rows: "
|
||||
+ result.metaData().metrics().totalRows());
|
||||
} catch (CouchbaseException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
----
|
||||
====
|
||||
|
||||
See link:https://docs.couchbase.com/java-sdk/current/howtos/full-text-searching-with-sdk.html[the FTS Documentation] for more information.
|
||||
Reference in New Issue
Block a user