public <RET extends ODocumentWrapper> RET reload() { document.reload(); return (RET) this; }
@Override public <RET extends ORecord> RET reload() throws ORecordNotFoundException { if (element != null) element.reload(); return (RET) this; }
@Override public <RET extends ORecord> RET reload(String fetchPlan, boolean ignoreCache, boolean force) throws ORecordNotFoundException { if (element != null) element.reload(fetchPlan, ignoreCache, force); return (RET) this; }
@Override public <RET extends ORecord> RET reload() throws ORecordNotFoundException { element.reload(); return (RET) this; }
@Override public <RET extends ORecord> RET reload(String fetchPlan, boolean ignoreCache, boolean force) throws ORecordNotFoundException { element.reload(fetchPlan, ignoreCache, force); return (RET) this; }
public <RET extends ODocumentWrapper> RET reload(final String iFetchPlan, final boolean iIgnoreCache) { document.reload(iFetchPlan, iIgnoreCache); return (RET) this; }
public <RET extends ODocumentWrapper> RET reload(final String iFetchPlan) { document.reload(iFetchPlan, true); return (RET) this; }
protected void reloadSequence() { tlDocument.set(tlDocument.get().reload(null, true)); }
public void reload() { final ODocument rec = getRecord(); if (rec != null) rec.reload(null, true); }
public Object call(ODatabaseDocumentInternal database) { if (iCurrent.getInternalStatus() == STATUS.NOT_LOADED) iCurrent.reload(); return null; } });
public Object call(ODatabaseDocumentInternal database) { if (iOther.getInternalStatus() == STATUS.NOT_LOADED) iOther.reload(); return null; } });
protected static ODocument getDocument(final OIdentifiable id, final boolean forceReload) { if (id == null) return null; final ODocument doc = id.getRecord(); if (doc != null && forceReload) { try { doc.reload(); } catch (ORecordNotFoundException e) { // IGNORE IT AND RETURN NULL } } return doc; }
@Override protected Boolean execute(ODatabaseDocument db) { int maxRetries = 50; OCommandSQL command = new OCommandSQL("update "+document.getIdentity()+" "+changeCommand); int retry = 0; while(true){ try { command.execute(value); break; } catch (OConcurrentModificationException e) { retry++; try { Thread.sleep((long) (Math.random()*150));} catch (InterruptedException e1) {} if (retry>=maxRetries){ throw e;//if all retries failed } } } document.reload(); return true; } }.execute();
@Override protected ODocument execute(ODatabaseDocument oDatabaseDocument) { ODocument document = user.getDocument(); document = (ODocument) document.reload(); document.field(ONLINE_FIELD, online); document.save(); return document; } }.execute();
@Override protected ODocument execute(ODatabaseDocument oDatabaseDocument) { ODocument document = user.getDocument(); document = (ODocument) document.reload(); document.field(LAST_SESSION_FIELD, sessionId); document.save(); return document; } }.execute();
public void removeEvent(final String eventName) { OLogManager.instance().debug(this, "Removing scheduled event '%s'...", eventName); final OScheduledEvent event = removeEventInternal(eventName); if (event != null) { try { event.getDocument().reload(); } catch (ORecordNotFoundException ignore) { // ALREADY DELETED, JUST RETURN return; } // RECORD EXISTS: DELETE THE EVENT RECORD ODatabaseDocumentAbstract.executeWithRetries(new OCallable<Object, Integer>() { @Override public Object call(Integer iArgument) { OLogManager.instance().debug(this, "Deleting scheduled event '%s' rid=%s...", event, event.getDocument().getIdentity()); event.getDocument().delete(); return null; } }, 10, 0, new ORecord[] { event.getDocument() }); } }
@Override public RESULT onRecordBeforeDelete(final ODocument iDocument) { final ORecordVersion version = iDocument.getRecordVersion(); // Cache the transaction-provided value if (iDocument.fields() == 0) { // FORCE LOADING OF CLASS+FIELDS TO USE IT AFTER ON onRecordAfterDelete METHOD iDocument.reload(); if (version.getCounter() > -1 && iDocument.getRecordVersion().compareTo(version) != 0) // check for record version errors if (OFastConcurrentModificationException.enabled()) throw OFastConcurrentModificationException.instance(); else throw new OConcurrentModificationException(iDocument.getIdentity(), iDocument.getRecordVersion(), version, ORecordOperation.DELETED); } return RESULT.RECORD_NOT_CHANGED; }
@Test public void testQueryAndUpdate() throws Exception { ODocument doc = (ODocument) wicket.getTester().getDatabase().browseClass(TEST_REST_CLASS).current(); String ret = wicket.getTester().executeUrl("orientdb/query/db/sql/select+from+"+TEST_REST_CLASS, "GET", null); assertTrue(ret.contains(doc.toJSON())); int nextB = RANDOM.nextInt(); ret = wicket.getTester().executeUrl("orientdb/command/db/sql", "POST", "update "+TEST_REST_CLASS+" set b = "+nextB, "admin", "admin"); doc.reload(); assertEquals(nextB, (Object) doc.field("b")); wicket.getTester().signOut(); }
@Test public void testGettingFields() { OSchema schema = wicket.getTester().getSchema(); OClass classA = schema.createClass("GettingFields"); classA.createProperty("title", OType.STRING); classA.createProperty("link", OType.LINK).setLinkedClass(classA); classA.createProperty("multi", OType.LINKLIST).setLinkedClass(classA); ODocument doc = new ODocument(classA); doc.field("title", "test"); doc.save(); doc.field("link", doc); doc.field("multi", Arrays.asList(doc)); doc.save(); doc.reload(); String title = doc.field("title"); ODocument link = doc.field("link"); Collection<ODocument> multi = doc.field("multi"); }
@Test @Sudo public void testCallbackHook() throws Exception { ODatabaseDocument db = OrientDbWebSession.get().getDatabase(); OSchema schema = db.getMetadata().getSchema(); OClass oClass = schema.createClass(TEST_CLASS_CALLBACK); oClass.createProperty("name", OType.STRING); try { ODocument doc = new ODocument(oClass); doc.field("name", "testname"); TestCallback callback = new TestCallback(); CallbackHook.registerCallback(doc, TYPE.AFTER_CREATE, callback); CallbackHook.registerCallback(doc, TYPE.BEFORE_CREATE, callback); doc.save(); assertEquals("executed", doc.field("callback"+TYPE.AFTER_CREATE)); assertEquals("executed", doc.field("callback"+TYPE.BEFORE_CREATE)); assertFalse(doc.containsField("__callbacks__")); doc.reload(); assertFalse(doc.containsField("__callbacks__")); assertFalse(doc.containsField("callback"+TYPE.AFTER_READ)); CallbackHook.registerCallback(doc, TYPE.AFTER_READ, callback); doc.reload(); assertEquals("executed", doc.field("callback"+TYPE.AFTER_READ)); } finally { schema.dropClass(TEST_CLASS_CALLBACK); } } }