void internalReleaseExclusiveLock() { lock.writeLock().unlock(); final ODatabaseDocument databaseRecord = getDatabaseIfDefined(); if (databaseRecord != null && !databaseRecord.isClosed()) { final OMetadata metadata = databaseRecord.getMetadata(); if (metadata != null) ((OMetadataInternal) metadata).clearThreadLocalSchemaSnapshot(); } }
/** * Delegates to the OQueryExecutor the query execution. */ @SuppressWarnings("unchecked") public List<T> run(final Object... iArgs) { final ODatabaseDocumentInternal database = ODatabaseRecordThreadLocal.instance().get(); if (database == null) throw new OQueryParsingException("No database configured"); ((OMetadataInternal) database.getMetadata()).makeThreadLocalSchemaSnapshot(); try { setParameters(iArgs); Object o = database.getStorage().command(this); if (o instanceof List) { return (List<T>) o; } else { return (List<T>) Collections.singletonList(o); } } finally { ((OMetadataInternal) database.getMetadata()).clearThreadLocalSchemaSnapshot(); } }
protected OGlobalProperty getGlobalPropertyById(int id) { if (_schema == null) { OMetadataInternal metadata = getDatabase().getMetadata(); _schema = metadata.getImmutableSchemaSnapshot(); } OGlobalProperty prop = _schema.getGlobalPropertyById(id); if (prop == null) { ODatabaseDocument db = getDatabase(); if (db == null || db.isClosed()) throw new ODatabaseException( "Cannot unmarshall the document because no database is active, use detach for use the document outside the database session scope"); OMetadataInternal metadata = (OMetadataInternal) db.getMetadata(); if (metadata.getImmutableSchemaSnapshot() != null) metadata.clearThreadLocalSchemaSnapshot(); metadata.reload(); metadata.makeThreadLocalSchemaSnapshot(); _schema = metadata.getImmutableSchemaSnapshot(); prop = _schema.getGlobalPropertyById(id); } return prop; }
database.getMetadata().clearThreadLocalSchemaSnapshot();