Search in sources :

Example 1 with RavenException

use of net.ravendb.client.exceptions.RavenException in project jnosql-diana-driver by eclipse.

the class RavenDBDocumentCollectionManager method update.

@Override
public DocumentEntity update(DocumentEntity entity) {
    Objects.requireNonNull(entity, "entity is required");
    try (IDocumentSession session = store.openSession()) {
        Document id = entity.find(EntityConverter.ID_FIELD).orElseThrow(() -> new RavenException("Id is required to Raven Update operation"));
        HashMap<String, Object> map = session.load(HashMap.class, id.get(String.class));
        map.putAll(EntityConverter.getMap(entity));
        session.saveChanges();
    }
    return entity;
}
Also used : RavenException(net.ravendb.client.exceptions.RavenException) IDocumentSession(net.ravendb.client.documents.session.IDocumentSession) Document(jakarta.nosql.document.Document)

Aggregations

Document (jakarta.nosql.document.Document)1 IDocumentSession (net.ravendb.client.documents.session.IDocumentSession)1 RavenException (net.ravendb.client.exceptions.RavenException)1