You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/cosmos-db/migrate-java-v4-sdk.md
+24-23Lines changed: 24 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,46 +15,46 @@ ms.reviewer: sngun
15
15
> For more information about this SDK, please view the Azure Cosmos DB Java SDK v4 Release notes, [Maven repository](https://mvnrepository.com/artifact/com.azure/azure-cosmos), Azure Cosmos DB Java SDK v4 [performance tips](performance-tips-java-sdk-v4-sql.md), and Azure Cosmos DB Java SDK v4 [troubleshooting guide](troubleshoot-java-sdk-v4-sql.md).
16
16
>
17
17
18
-
This article explains how to upgrade your existing Java application that is using older Azure Cosmos DB Java SDK to the newer Java SDK 4.0 for Core (SQL) API. The Java V4 SDK corresponds to the `com.azure.cosmos` package. You can use the instructions in this doc if you are migrating your application from any of the following SDKs:
18
+
This article explains how to upgrade your existing Java application that is using older Azure Cosmos DB Java SDK to the newer Java SDK 4.0 for Core (SQL) API. The Azure Cosmos DB Java SDK v4 corresponds to the `com.azure.cosmos` package. You can use the instructions in this doc if you are migrating your application from any of the following Azure Cosmos DB Java SDKs:
19
19
20
-
*Legacy Sync Java SDK 2.x.x
20
+
* Sync Java SDK 2.x.x
21
21
* Async Java SDK 2.x.x
22
22
* Java SDK 3.x.x
23
23
24
-
## Java SDK’s and package mappings
24
+
## Azure Cosmos DB Java SDK’s and package mappings
25
25
26
26
The following table lists different Azure Cosmos DB Java SDKs, the package name and the release information:
27
27
28
28
| Java SDK| Release Date | Bundled APIs | Maven Jar | Java package name |API Reference | Release Notes |
The following are the key implementation differences between different SDKs:
38
38
39
-
### RxJava is replaced with reactor in Java 3.x.x and 4.0 SDKs
39
+
### RxJava is replaced with reactor in Azure Cosmos DB Java SDK versions 3.x.x and 4.0
40
40
41
-
If you have been using the 3.x.x Java SDK or the preview versions of that SDK and migrating to the 4.0 SDK, see the [Reactor pattern guide](https://github.com/Azure-Samples/azure-cosmos-java-sql-api-samples/blob/master/reactor-pattern-guide.md) for an introduction to async programming and Reactor.
41
+
If you are unfamiliar with asynchronous programming or Reactive Programming, see the [Reactor pattern guide](https://github.com/Azure-Samples/azure-cosmos-java-sql-api-samples/blob/master/reactor-pattern-guide.md) for an introduction to async programming and Project Reactor. This guide may be useful if you have been using Azure Cosmos DB Sync Java SDK 2.x.x or Azure Cosmos DB Java SDK 3.x.x Sync API in the past.
42
42
43
-
If you have been using Async Java SDK 2.x.x, and migrating to the 4.0 SDK, see the [Reactor vs RxJava Guide](https://github.com/Azure-Samples/azure-cosmos-java-sql-api-samples/blob/master/reactor-rxjava-guide.md) for guidance on converting RxJava code to use Reactor.
43
+
If you have been using Azure Cosmos DB Async Java SDK 2.x.x, and you plan on migrating to the 4.0 SDK, see the [Reactor vs RxJava Guide](https://github.com/Azure-Samples/azure-cosmos-java-sql-api-samples/blob/master/reactor-rxjava-guide.md) for guidance on converting RxJava code to use Reactor.
44
44
45
-
### Java SDK 4.0 has direct connectivity mode in both Async and Sync APIs
45
+
### Azure Cosmos DB Java SDK v4 has direct connectivity mode in both Async and Sync APIs
46
46
47
-
If you have been using the legacy Sync Java SDK 2.x.x, note that the direct connection mode based on TCP (as opposed to HTTP) is implemented in Java SDK 4.0 for both the Async and Sync APIs.
47
+
If you have been using Azure Cosmos DB Sync Java SDK 2.x.x, note that the direct connection mode based on TCP (as opposed to HTTP) is implemented in Azure Cosmos DB Java SDK 4.0 for both the Async and Sync APIs.
48
48
49
49
## API level changes
50
50
51
-
The following are the API level changes between Java 3.x.x Vs 4.x.x SDK and Async Java SDK 2.x.x and Legacy sync Java SDK 2.x.x:
51
+
The following are the API level changes in Azure Cosmos DB Java SDK 4.x.x compared to previous SDKs (Java SDK 3.x.x, Async Java SDK 2.x.x, and Sync Java SDK 2.x.x):
52
52
53
53

54
54
55
-
* The Java SDK 3.x.x and 4.0 refer the client resources as `Cosmos<resourceName>`. For example, `CosmosClient`, `CosmosDatabase`, `CosmosContainer`. Whereas in version 2.x.x, the Java SDKs doesn’t have a uniform naming scheme.
55
+
* The Azure Cosmos DB Java SDK 3.x.x and 4.0 refer the client resources as `Cosmos<resourceName>`. For example, `CosmosClient`, `CosmosDatabase`, `CosmosContainer`. Whereas in version 2.x.x, the Azure Cosmos DB Java SDKs don’t have a uniform naming scheme.
56
56
57
-
*The Java SDK 3.x.x and 4.0 offer both Sync and Async APIs.
57
+
*Azure Cosmos DB Java SDK 3.x.x and 4.0 offer both Sync and Async APIs.
58
58
59
59
***Java SDK 4.0** : All the classes belong to the Sync API unless the class name is appended with `Async` after `Cosmos`.
60
60
@@ -64,31 +64,31 @@ The following are the API level changes between Java 3.x.x Vs 4.x.x SDK and Asyn
64
64
65
65
### Hierarchical API structure
66
66
67
-
The Java SDK 4.0 and Java SDK 3.x.x introduces a hierarchical API structure that organizes the clients, databases, and containers in a nested fashion as shown in the following 4.0 SDK code snippet:
67
+
Azure Cosmos DB Java SDK 4.0 and 3.x.x introduce a hierarchical API structure that organizes the clients, databases, and containers in a nested fashion as shown in the following 4.0 SDK code snippet:
In version 2.x.x of Java SDKs, all operations on resources and documents are performed through the client instance.
73
+
In version 2.x.x of the Azure Cosmos DB Java SDK, all operations on resources and documents are performed through the client instance.
74
74
75
75
### Representing documents
76
76
77
-
In Java SDK 4.0, custom POJO's and `JsonNodes` are the two options to read and write the documents from Azure Cosmos DB.
77
+
In Azure Cosmos DB Java SDK 4.0, custom POJO's and `JsonNodes` are the two options to read and write the documents from Azure Cosmos DB.
78
78
79
-
In the Java SDK 3.x.x, the `CosmosItemProperties` object is exposed by the public API and served as a document representation. This class is no longer exposed in Java SDK 4.0.
79
+
In the Azure Cosmos DB Java SDK 3.x.x, the `CosmosItemProperties` object is exposed by the public API and served as a document representation. This class is no longer exposed publicly in version 4.0.
80
80
81
81
### Imports
82
82
83
-
* The Java SDK 4.0 packages begin with `com.azure.cosmos`
84
-
* Java SDK 3.x.x packages begin with `com.azure.data.cosmos`
83
+
* The Azure Cosmos DB Java SDK 4.0 packages begin with `com.azure.cosmos`
84
+
*Azure Cosmos DB Java SDK 3.x.x packages begin with `com.azure.data.cosmos`
85
85
86
-
* Java SDK 4.0 places several classes in a nested package `com.azure.cosmos.models`. Some of these packages include:
86
+
*Azure Cosmos DB Java SDK 4.0 places several classes in a nested package `com.azure.cosmos.models`. Some of these packages include:
87
87
88
88
*`CosmosContainerResponse`
89
89
*`CosmosDatabaseResponse`
90
90
*`CosmosItemResponse`
91
-
* The Async API analogs for all the above packages
91
+
* The Async API analogs for all of the above packages
92
92
*`CosmosContainerProperties`
93
93
*`FeedOptions`
94
94
*`PartitionKey`
@@ -97,9 +97,9 @@ In the Java SDK 3.x.x, the `CosmosItemProperties` object is exposed by the publi
97
97
98
98
### Accessors
99
99
100
-
The Java SDK 4.0 exposes `get` and `set` methods to access the instance members. For example, the `CosmosContainer` instance has `container.getId()` and `container.setId()` methods.
100
+
Azure Cosmos DB Java SDK 4.0 exposes `get` and `set` methods to access the instance members. For example, the `CosmosContainer` instance has `container.getId()` and `container.setId()` methods.
101
101
102
-
This is different from Java SDK 3.x.x which exposes a fluent interface. For example, a `CosmosSyncContainer` instance has `container.id()` which is overloaded to get or set the `id` value.
102
+
This is different from Azure Cosmos DB Java SDK 3.x.x which exposes a fluent interface. For example, a `CosmosSyncContainer` instance has `container.id()` which is overloaded to get or set the `id` value.
103
103
104
104
## Code snippet comparisons
105
105
@@ -541,4 +541,5 @@ SalesOrder salesOrder = new SalesOrder(
541
541
## Next steps
542
542
543
543
*[Build a Java app](create-sql-api-java.md) to manage Azure Cosmos DB SQL API data using the V4 SDK
544
-
* Learn about the [Reactor-based Java SDKs](https://github.com/Azure-Samples/azure-cosmos-java-sql-api-samples/blob/master/reactor-pattern-guide.md)
544
+
* Learn about the [Reactor-based Java SDKs](https://github.com/Azure-Samples/azure-cosmos-java-sql-api-samples/blob/master/reactor-pattern-guide.md)
545
+
* Learn about converting RxJava async code to Reactor async code with the [Reactor vs RxJava Guide](https://github.com/Azure-Samples/azure-cosmos-java-sql-api-samples/blob/master/reactor-rxjava-guide.md)
0 commit comments