Skip to content
This repository was archived by the owner on Aug 29, 2024. It is now read-only.
This repository was archived by the owner on Aug 29, 2024. It is now read-only.

how to suppress null values in cosmos-db spring repository save method #141

@senthilkrishnankr

Description

@senthilkrishnankr

Hello,

I have a repository called "Shipment" which has following structure. I am noticing that Null values are not being suppressed when we try to insert using repository.save(shipmentObject) method. But Null values are being suppressed while using documentClient.upsertDocument(shipmentObject) method. how can we suppress null values being stored in cosmosDB when we use springdata cosmosdb?

Code Snippet:

Shipment shipment = new Shipment();
shipment.setShipementID(id);
Shipment sp = shipmentRepository.save(shipment); ==> null values being stored in "shipmentmessage" field
documentClient.upsertDocument(shipment) ==> null values are not stored in  "shipmentmessage"  field

Shipment Repository Bean:
@JsonInclude(Include.NON_NULL)
@Document(collection = "shipment")
@DocumentIndexingPolicy(mode = IndexingMode.Lazy)
public class Shipment {
	@Id
	@JsonProperty("id")
String id;
String shipmentMessage;
...
}
Expected Output:
{
    "id": "436",
    "_rid": "Io1rAM1GtAAuAAAAAAAAAA==",
    "_self": "dbs/Io1rAA==/colls/Io1rAM1GtAA=/docs/Io1rAM1GtAAuAAAAAAAAAA==/",
    "_etag": "\"04001d06-0000-0000-0000-5b44304d0000\"",
    "_attachments": "attachments/",
    "_ts": 1531195469
}

Actual Output:
{
    "id": "436",
"shipmentMessage":null,
    "_rid": "Io1rAM1GtAAuAAAAAAAAAA==",
    "_self": "dbs/Io1rAA==/colls/Io1rAM1GtAA=/docs/Io1rAM1GtAAuAAAAAAAAAA==/",
    "_etag": "\"04001d06-0000-0000-0000-5b44304d0000\"",
    "_attachments": "attachments/",
    "_ts": 1531195469
}

Please let me know if you need additional details.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions