graphdb/src/main/java/com/orientechnologies/orient/graph/sql/OGraphCommandExecutorSQLFactory.java
public static OrientGraph getGraph(final boolean autoStartTx, OModifiableBoolean shouldBeShutDown) {
    final ODatabaseDocumentInternal database = ODatabaseRecordThreadLocal.instance().get();

    final OrientBaseGraph result = OrientBaseGraph.getActiveGraph();

    if (result != null && (result instanceof OrientGraph)) {
      final ODatabaseDocumentInternal graphDb = result.getRawGraph();

      // CHECK IF THE DATABASE + USER IN TL IS THE SAME IN ORDER TO USE IT
      if (canReuseActiveGraph(graphDb, database)) {

        if (!graphDb.isClosed()) {
          ODatabaseRecordThreadLocal.instance().set(graphDb);
          if (autoStartTx && autoTxStartRequired(graphDb))
            ((OrientGraph) result).begin();

          shouldBeShutDown.setValue(false);
          return (OrientGraph) result;
        }
      }
    }
    // Set it again on ThreadLocal because the getRawGraph() may have set a closed db in the thread-local
    ODatabaseRecordThreadLocal.instance().set(database);
    shouldBeShutDown.setValue(true);

    final OrientGraph g = (OrientGraph) OrientGraphFactory.getTxGraphImplFactory().getGraph(database, false);
    if (autoStartTx && autoTxStartRequired(database))
      g.begin();
    return g;
  }
public static OrientGraph getGraph(final boolean autoStartTx, OModifiableBoolean shouldBeShutDown) {
    final ODatabaseDocumentInternal database = ODatabaseRecordThreadLocal.instance().get();

    final OrientBaseGraph result = OrientBaseGraph.getActiveGraph();

    if (result != null && (result instanceof OrientGraph)) {
      final ODatabaseDocumentInternal graphDb = result.getRawGraph();

      // CHECK IF THE DATABASE + USER IN TL IS THE SAME IN ORDER TO USE IT
      if (canReuseActiveGraph(graphDb, database)) {

        if (!graphDb.isClosed()) {
          ODatabaseRecordThreadLocal.instance().set(graphDb);
          if (autoStartTx && autoTxStartRequired(graphDb))
            ((OrientGraph) result).begin();

          shouldBeShutDown.setValue(false);
          return (OrientGraph) result;
        }
      }
    }
    // Set it again on ThreadLocal because the getRawGraph() may have set a closed db in the thread-local
    ODatabaseRecordThreadLocal.instance().set(database);
    shouldBeShutDown.setValue(true);

    final OrientGraph g = (OrientGraph) OrientGraphFactory.getTxGraphImplFactory().getGraph(database, false);
    if (autoStartTx && autoTxStartRequired(database))
      g.begin();
    return g;
  }
public static OrientGraph getGraph ( final boolean autoStartTx , OModifiableBoolean shouldBeShutDown ) { final ODatabaseDocumentInternal database = ODatabaseRecordThreadLocal . instance ( ) . get ( ) ; final OrientBaseGraph result = OrientBaseGraph . getActiveGraph ( ) ; if ( result != null && ( result instanceof OrientGraph ) ) { final ODatabaseDocumentInternal graphDb = result . getRawGraph ( ) ; // CHECK IF THE DATABASE + USER IN TL IS THE SAME IN ORDER TO USE IT if ( canReuseActiveGraph ( graphDb , database ) ) { if ( ! graphDb . isClosed ( ) ) { ODatabaseRecordThreadLocal . instance ( ) . set ( graphDb ) ; if ( autoStartTx && autoTxStartRequired ( graphDb ) ) ( ( OrientGraph ) result ) . begin ( ) ; shouldBeShutDown . setValue ( false ) ; return ( OrientGraph ) result ; } } } // Set it again on ThreadLocal because the getRawGraph() may have set a closed db in the thread-local ODatabaseRecordThreadLocal . instance ( ) . set ( database ) ; shouldBeShutDown . setValue ( true ) ; final OrientGraph g = ( OrientGraph ) OrientGraphFactory . getTxGraphImplFactory ( ) . getGraph ( database , false ) ; if ( autoStartTx && autoTxStartRequired ( database ) ) g . begin ( ) ; return g ; }
Returns a Transactional OrientGraph implementation from the current database in thread local.

@param autoStartTx Whether returned graph will start transaction before each operation till commit automatically or user should do it
explicitly be calling {@link OrientGraph#getRawGraph()} method {@link ODatabaseDocumentTx#begin()}.
@return Transactional OrientGraph implementation from the current database in thread local.
Returns a Transactional OrientGraph implementation from the current database in thread local .