document failed to save on update using 1.6.x #1867

yahonggu opened this Issue Dec 4, 2013 · 3 comments

2 participants


we found that the odocument is not able to save during update, i.e. saving a new odocument works fine, when we update some fields and save the 2nd time, the changes are not persisted. The same code works fine on 1.4.1 and 1.5.0.

OrientDB member

May you provide a piece of code? Otherwise we would need a witch to understand your problem! :-)

@lvca lvca was assigned Dec 4, 2013

Sure, thanks for the quick response :), below is the relevant code:

/** We uses embedded database, and here is the method building storage configuration */
private OServerStorageConfiguration buildStorageConfiguration() {
OServerStorageConfiguration storage = new OServerStorageConfiguration();
storage.path = "local:" + settingsService.getOrientDbLocation(); = "odin";
storage.loadOnStartup = true;
storage.userName = settingsService.getOrientDbUsername();
storage.userPassword = settingsService.getOrientDbPassword();
return storage;

/** here is how we call the save using a callpack */

public <S extends T> S save(final S entity) {


    ODocument document = orientDbTemplate.executeWithTx(new DocumentTxCallback<ODocument>() {

        public ODocument withDocumentTx(ODatabaseDocumentTx documentTx) {

            OIdentifiable existing = findExisting(documentTx, entity.getId());

            ODocument document = null;

            if (existing != null) {

                document = existing.getRecord();
                T existingEntity = gson.get().fromJson(existing.getRecord().toJSON(), typeOfT);

                updateExistingWith(existingEntity, entity);
                LOG.debug("Updating existing document with id " + entity.getId());
            } else {

                document = documentTx.newInstance();
                LOG.debug("Creating new document with id " + entity.getId());
            document =;

            return document;

    final T savedEntity = gson.get().fromJson(document.toJSON(), typeOfT);
    return (S) savedEntity;


/** here is the orentDbTemplate call*/
public T executeWithTx(DocumentTxCallback callback) {

    ODatabaseDocumentTx documentTx = documentPool.acquire();

    try {

        T result = callback.withDocumentTx(documentTx);

        return result;
    } finally {

@lvca lvca modified the milestone: 2.0rc1, 2.1 Aug 28, 2014
OrientDB member

Is this still valid?

@lvca lvca closed this Aug 28, 2014
@lvca lvca removed this from the 2.1 milestone Aug 28, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment