Composite Key azure cosmos java

Deepak Patil 61 Reputation points
2022-02-04T12:51:00.46+00:00

@alrt
@MetContainer (containerName = "tag")
@TostringsOwO
@EqualsAndHashCode
@Builder
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@NoArgsConstructor
@AllArgsConstructor
public class Tag {

@Id  
private String tagName;  

@Id  
private String domainName;  

@PartitionKey  
private String countryDcOrgUnit;  

}

I need to create container with name tag having tagName and domainName as unique combination.... but after running this i am getting error .. only one field with @Id annotation!
how to crate container with composite key as primary key

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,452 questions
{count} votes

1 additional answer

Sort by: Most helpful
  1. Oury Ba-MSFT 16,556 Reputation points Microsoft Employee
    2022-03-01T00:51:24.953+00:00

    You can use the feature of Nested Partition Key Path in azure-spring-data-cosmos to solve the unique key problem in spring - https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/cosmos/azure-spring-data-cosmos/README.md#nested-partition-key-support.

    178661-image.png

    0 comments No comments