/** * {@inheritDoc} * Flushes locally cached to content in memory to remote OrientDB server. */ @Override public void flush() throws GoraException { try (ODatabaseDocumentTx updateTx = connectionPool.acquire()) { updateTx.activateOnCurrentThread(); flushLock.lock(); for (ODocument document : docBatch) { updateTx.save(document); } } catch (Exception e) { throw new GoraException(e); } finally { docBatch.clear(); flushLock.unlock(); } }
/** * Implementation to save entity to database * @param entity to be saved * @return true if saving succeeded */ public boolean save(T entity) { try { initDb(); // process before saving entity = processBeforeSaving(entity); // save ODocument updated = db.save(convertToDocument(entity)); // process after saving processAfterSaving(updated, entity); if (logger.isInfoEnabled()) logger.info("Saved entity: " + entity.toString()); return true; } catch (Exception e) { logger.error("Exception thrown while saving entity.", e); } return false; }
@Override public void create(T entity, OPersistenceSession session) { ODocument doc = mapToODocument(entity, null, session); session.getDatabase().save(doc); session.cacheODocument(doc); }
@Override public void update(T entity, OPersistenceSession session) { ODocument doc = readAsDocument(entity.getId(), session); mapToODocument(entity, doc, session); session.getDatabase().save(doc); }
ODocument updated = db.save(document);
ORID rid = document.getIdentity(); if (rid.getClusterId() != primaryClusterId) { db.save(new ODocument(document.toStream())); db.delete(rid); moveCount++;
.field("active", true) .field("special", "ADMIN"); db.save(userGroup); groupCreated = true; db.save(doc); .field("color", Long.decode(color)) .field("created", currentTime).field("modified", currentTime); db.save(doc); .field("active", true) .field("special", "ADMIN"); db.save(doc); .field("active", true) .field("special", "ANONYMOUS"); db.save(doc); } catch (Exception e) { logger.error("Could not update UserGroup: " + e.getMessage());
log(OETLProcessor.LOG_LEVELS.DEBUG, "saving record %s", doc); final ODatabaseDocumentTx db = super.pipeline.getDocumentDatabase(); db.save(doc);