doc.calculateTreeLevelStartPoints();
try { doc.calculateTreeLevelStartPoints(); } catch(EXistException e) { }
    public void storeDocument( DocumentImpl doc ) {        Object lock = documentsLock.acquire();        String docName = doc.getFileName();        docName = NativeBroker.normalizeCollectionName( docName );        if ( docName.length() > 0 && docName.charAt( 0 ) != '/' )            docName = "/" + docName;        if ( !docName.startsWith( "/db" ) )            docName = "/db" + docName;        if ( docName.endsWith( "/" ) && docName.length() > 1 )            docName = docName.substring( 0, docName.length() - 1 );        try {            if ( mDatabaseType != MYSQL )                m_insertDocStmt.getConnection().setAutoCommit( true );            int doc_id = doc.getDocId();            if(doc_id < 0)                doc_id = getNextDocId(null);            m_insertDocStmt.setInt( 1, doc_id );            m_insertDocStmt.setString( 2, docName );            m_insertDocStmt.setInt( 3, doc.getChildCount() );            DocumentTypeImpl doctype = (DocumentTypeImpl) doc.getDoctype();            if ( doctype == null ) {                m_insertDocStmt.setString( 4, null );                m_insertDocStmt.setString( 5, null );                m_insertDocStmt.setString( 6, null );            }            else {                m_insertDocStmt.setString( 4, doctype.getName() );                m_insertDocStmt.setString( 5, doctype.getPublicId() );                m_insertDocStmt.setString( 6, doctype.getSystemId() );            }            m_insertDocStmt.execute();            if ( mDatabaseType != MYSQL )                m_insertDocStmt.getConnection().commit();            doc.setDocId( doc_id );            doc.calculateTreeLevelStartPoints();            for ( int i = 0; i < doc.getMaxDepth(); i++ ) {                m_insertTreeInfo.setInt( 1, doc_id );                m_insertTreeInfo.setInt( 2, doc.getTreeLevelOrder( i ) );                m_insertTreeInfo.setInt( 3, i );                m_insertTreeInfo.setLong( 4, doc.getLevelStartPoint( i ) );                m_insertTreeInfo.setLong( 5, doc.getLevelStartPoint( i + 1 ) );                m_insertTreeInfo.executeUpdate();            }            if ( mDatabaseType != MYSQL )                m_insertDocStmt.getConnection().setAutoCommit( false );        } catch ( SQLException e ) {            LOG.debug( "storeDocument(): " + e );        } finally {            documentsLock.release( lock );        }    }