/*
Persist the session change - session must already exist in database
427749
protected boolean persistSession(BackedSession d2, boolean propHit) {
        if (com.ibm.websphere.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) {
            LoggingUtil.SESSION_LOGGER_WAS.entering(methodClassName, methodNames[PERSIST_SESSION]);
        }

        Connection con = null;
        String id = d2.getId();
        Thread t = Thread.currentThread();
        PreparedStatement ps = null;
        boolean psClose = false;
        byte[] objbuf = null;
        int objbufLength = 0;

        try {
            // build update string based on what has changed
            d2.update = new StringBuffer();
            boolean didFirstCol = false;

            d2.update.append(upBase);
            if (d2.userWriteHit) {
                if (didFirstCol) {
                    d2.update.append(comma);
                }
                d2.update.append(userCol).append(equals);
                didFirstCol = true;
            }

            if (d2.maxInactWriteHit) {
                if (didFirstCol) {
                    d2.update.append(comma);
                } else {
                    didFirstCol = true;
                }
                d2.update.append(maxInactCol).append(equals);
            }

            if (d2.listenCntHit) {
                if (didFirstCol) {
                    d2.update.append(comma);
                } else {
                    didFirstCol = true;
                }
                d2.update.append(listenCol).append(equals);
            }

            if (!_smc.getEnableEOSWrite() || _smc.getScheduledInvalidation()) {
                if (didFirstCol) {
                    d2.update.append(comma);
                } else {
                    didFirstCol = true;
                }
                d2.update.append(lastAccCol).append(equals);
            }

            if (propHit) {
                if (!_smc.isUsingMultirow()) {
                    if (didFirstCol) {
                        d2.update.append(comma);
                    } else {
                        didFirstCol = true;
                    }
                    objbuf = serializeAppData(d2);
                    if (objbuf != null) {
                        objbufLength = objbuf.length;
                    }
                }

                boolean success = handlePropertyHits(d2, t, objbufLength);
                if (!success) { //325643
                    if (com.ibm.websphere.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) {
                        LoggingUtil.SESSION_LOGGER_WAS.logp(Level.FINE, methodClassName, methodNames[PERSIST_SESSION], "returning false after handlePropertyHits");
                    }
                    return false; // 325643
                }
            }

            // if nothing changed, then just return
            if (!didFirstCol) {
                d2.update = null;
                d2.userWriteHit = false;
                d2.maxInactWriteHit = false;
                d2.listenCntHit = false;
                if (com.ibm.websphere.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINER)) {
                    LoggingUtil.SESSION_LOGGER_WAS.exiting(methodClassName, methodNames[PERSIST_SESSION], "true - Nothing changed");
                }
                return true;
            } else {
                d2.update.append(upId);
            }

            con = getConnection(false);
            if (com.ibm.websphere.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) {
                LoggingUtil.SESSION_LOGGER_WAS.logp(Level.FINE, methodClassName, methodNames[PERSIST_SESSION], "thread " + t + " is dealing with session " + id);
            }

            if (con == null) {
                if (com.ibm.websphere.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINER)) {
                    LoggingUtil.SESSION_LOGGER_WAS.exiting(methodClassName, methodNames[PERSIST_SESSION], "null connection on id " + id);
                }
                return false;
            }

            ps = con.prepareStatement(d2.update.toString());
            long startTime = System.currentTimeMillis();
            if (com.ibm.websphere.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) {
                LoggingUtil.SESSION_LOGGER_WAS.logp(Level.FINE, methodClassName, methodNames[PERSIST_SESSION], "doing a sql update of " + d2.update.toString());
            }
            int colcnt = 0;

            if (d2.userWriteHit) {
                if (com.ibm.websphere.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) {
                    LoggingUtil.SESSION_LOGGER_WAS.logp(Level.FINE, methodClassName, methodNames[PERSIST_SESSION], "update username " + d2.getUserName());
                }
                colcnt++;
                ps.setString(colcnt, d2.getUserName());
                d2.userWriteHit = false;
            }

            if (d2.maxInactWriteHit) {
                if (com.ibm.websphere.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) {
                    LoggingUtil.SESSION_LOGGER_WAS.logp(Level.FINE, methodClassName, methodNames[PERSIST_SESSION], "update maxinactive " + d2.getMaxInactiveInterval());
                }
                colcnt++;
                ps.setInt(colcnt, d2.getMaxInactiveInterval());
                d2.maxInactWriteHit = false;
            }

            if (d2.listenCntHit) {
                if (com.ibm.websphere.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) {
                    LoggingUtil.SESSION_LOGGER_WAS.logp(Level.FINE, methodClassName, methodNames[PERSIST_SESSION], "update listerncnt " + d2.listenerFlag);
                }
                colcnt++;
                ps.setShort(colcnt, d2.listenerFlag);
                d2.listenCntHit = false;
            }

            ByteArrayInputStream bis = null;
            long time = d2.getCurrentAccessTime();
            if (!_smc.getEnableEOSWrite() || _smc.getScheduledInvalidation()) {
                if (com.ibm.websphere.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) {
                    LoggingUtil.SESSION_LOGGER_WAS.logp(Level.FINE, methodClassName, methodNames[PERSIST_SESSION], "update last write time to DB !!!!!!! " + time);
                }
                colcnt++;
                // shouldn't get a -1 time since already stored...
                // I'm assuming lastAccess has been updated in the session object
                setPSLong(ps, colcnt, time);
                d2.setLastWriteLastAccessTime(time);

            }

            // not done in multirow, MR's handlePropertyHits will reset flag
            if (propHit && !_smc.isUsingMultirow()) {
                if (com.ibm.websphere.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) {
                    LoggingUtil.SESSION_LOGGER_WAS.logp(Level.FINE, methodClassName, methodNames[PERSIST_SESSION], "update  " + time); // cmd 200713
                }
                colcnt++;

                if ((!usingInformix) && (!_smc.isUseOracleBlob())) {
                    ps.setBytes(colcnt, objbuf);
                } else {

                    bis = new ByteArrayInputStream(objbuf);
                    ps.setBinaryStream(colcnt, (InputStream) bis, objbufLength);
                }
            }

            colcnt++;
            ps.setString(colcnt, id);

            colcnt++;
            ps.setString(colcnt, id);

            colcnt++; //*dbc2.2
            ps.setString(colcnt, d2.getAppName()); //*dbc2.2

            if (com.ibm.websphere.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) {
                LoggingUtil.SESSION_LOGGER_WAS.logp(Level.FINE, methodClassName, methodNames[PERSIST_SESSION], "before upd " + d2.update.toString() + " for sess " + id);
            }

            ps.executeUpdate();

            if (objbuf != null && propHit && !_smc.isUsingMultirow()) {
                SessionStatistics pmiStats = _iStore.getSessionStatistics();
                if (pmiStats != null) {
                    pmiStats.writeTimes(objbuf.length, System.currentTimeMillis() - startTime);
                }
            }

            if (com.ibm.websphere.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) {
                LoggingUtil.SESSION_LOGGER_WAS.logp(Level.FINE, methodClassName, methodNames[PERSIST_SESSION], "Just wrote out Primary Row ");
            }
            ps.close();
            psClose = true;

            if (com.ibm.websphere.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) {
                LoggingUtil.SESSION_LOGGER_WAS.logp(Level.FINE, methodClassName, methodNames[PERSIST_SESSION], "thread " + t + " has sent updates for " + id);
            }
        } catch (SQLException se) {
            //            if (isStaleConnectionException(se)) {
            //                com.ibm.ws.ffdc.FFDCFilter.processException(se, "com.ibm.ws.session.store.db.DatabaseHashMap.persistSession", "2094", d2);
            //                if (com.ibm.websphere.ras.TraceComponent.isAnyTracingEnabled()&&LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINER)) {
            //                    LoggingUtil.SESSION_LOGGER_WAS.exiting(methodClassName, methodNames[PERSIST_SESSION], "StaleConnectionException");
            //                }
            //            } else {
            com.ibm.ws.ffdc.FFDCFilter.processException(se, "com.ibm.ws.session.store.db.DatabaseHashMap.persistSession", "2099", d2);
            LoggingUtil.SESSION_LOGGER_WAS.logp(Level.SEVERE, methodClassName, methodNames[PERSIST_SESSION], "DatabaseHashMap.ejbStoreError");
            LoggingUtil.SESSION_LOGGER_WAS.logp(Level.SEVERE, methodClassName, methodNames[PERSIST_SESSION], "CommonMessage.object", d2.toString());
            LoggingUtil.SESSION_LOGGER_WAS.logp(Level.SEVERE, methodClassName, methodNames[PERSIST_SESSION], "CommonMessage.miscData", " Update string: " + d2.update);
            LoggingUtil.SESSION_LOGGER_WAS.logp(Level.SEVERE, methodClassName, methodNames[PERSIST_SESSION], "CommonMessage.exception", se);
            //            }
            return false;
        } catch (Exception ee) {
            com.ibm.ws.ffdc.FFDCFilter.processException(ee, "com.ibm.ws.session.store.db.DatabaseHashMap.ejbStore", "1994", d2);
            LoggingUtil.SESSION_LOGGER_WAS.logp(Level.SEVERE, methodClassName, methodNames[PERSIST_SESSION], "DatabaseHashMap.ejbStoreError");
            LoggingUtil.SESSION_LOGGER_WAS.logp(Level.SEVERE, methodClassName, methodNames[PERSIST_SESSION], "CommonMessage.object", d2.toString());
            LoggingUtil.SESSION_LOGGER_WAS.logp(Level.SEVERE, methodClassName, methodNames[PERSIST_SESSION], "CommonMessage.exception", ee);
            return false;
        } finally {
            if (!psClose && ps != null)
                closeStatement(ps);
            if (con != null)
                closeConnection(con);
        }
        if (com.ibm.websphere.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINER)) {
            LoggingUtil.SESSION_LOGGER_WAS.exiting(methodClassName, methodNames[PERSIST_SESSION], Boolean.valueOf(true));
        }
        return true;
    }
395040
private function updateValue()
    {
        $session = $this->getSessionStorage();
        $input   = $this->getInputProvider();
        $value   = null;

        if ($input->hasValue($this->getPropertyName()) && $this->getPanel()->getContainer()->updateValues()) {
            $value = $input->getValue($this->getPropertyName());

            $this->setPersistent($value);
        }

        if ($session->has('filter')) {
            $persistent = $this->getPersistent();
            $value      = $persistent;
        }

        if (null !== $value) {
            $this->setValue($value);
        }
    }
479065
@Override
  public Deferred<Object> persist() {
    final byte[] q = Arrays.copyOfRange(batched_qualifier, 0, qualifier_index);
    final byte[] v = Arrays.copyOfRange(batched_value, 0, value_index);
    final byte[] r = Arrays.copyOfRange(row_key, 0, row_key.length);
    final long base_time = this.base_time; // shadow fixes issue #1436
    System.out.println(Arrays.toString(q) + "  " + Arrays.toString(v) + "  " + Arrays.toString(r));
    reset();
    return tsdb.put(r, q, v, base_time);
  }
1366475
void checkInsert(Session session, Table table, Object[] row) {

        switch (constType) {

            case CHECK :
                if (!isNotNull) {
                    checkCheckConstraint(session, table, row);
                }

                return;

            case FOREIGN_KEY :
                PersistentStore store =
                    session.sessionData.getRowStore(core.mainTable);

                if (ArrayUtil.hasNull(row, core.refCols)) {
                    if (core.matchType == OpTypes.MATCH_SIMPLE) {
                        return;
                    }

                    if (core.refCols.length == 1) {
                        return;
                    }

                    if (ArrayUtil.hasAllNull(row, core.refCols)) {
                        return;
                    }

                    // core.matchType == OpTypes.MATCH_FULL
                } else if (core.mainIndex.exists(session, store, row,
                                                 core.refCols)) {
                    return;
                } else if (core.mainTable == core.refTable) {

                    // special case: self referencing table and self referencing row
                    int compare = core.mainIndex.compareRowNonUnique(row,
                        core.refCols, row);

                    if (compare == 0) {
                        return;
                    }
                }

                String[] info = new String[] {
                    core.refName.name, core.mainTable.getName().name
                };

                throw Error.error(ErrorCode.X_23502, ErrorCode.CONSTRAINT,
                                  info);
        }
    }
271768
def save(self, must_create=False):
        
        obj = Session(
            session_key=self._get_or_create_session_key(),
            session_data=self.encode(self._get_session(no_load=must_create)),
            expire_date=self.get_expiry_date(),
            user_agent=self.user_agent,
            user_id=self.user_id,
            ip=self.ip,
        )
        using = router.db_for_write(Session, instance=obj)
        try:
            with transaction.atomic(using):
                obj.save(force_insert=must_create, using=using)
        except IntegrityError as e:
            if must_create and 'session_key' in str(e):
                raise CreateError
            raise
61047
@Override
    public void insert(Session session, PersistentStore store, Row row) {

        NodeAVL n;
        NodeAVL x;
        boolean isleft  = true;
        int     compare = -1;

        writeLock.lock();

        try {
            n = getAccessor(store);
            x = n;

            if (n == null) {
                store.setAccessor(this, ((RowAVL) row).getNode(position));

                return;
            }

            while (true) {
                Row currentRow = n.getRow(store);

                compare = compareRowForInsertOrDelete(session, row,
                                                      currentRow);

                if (compare == 0) {
                    throw Error.error(ErrorCode.X_23505);
                }

                isleft = compare < 0;
                x      = n;
                n      = child(store, x, isleft);

                if (n == null) {
                    break;
                }
            }

            x = set(store, x, isleft, ((RowAVL) row).getNode(position));

            balance(store, x, isleft);
        } finally {
            writeLock.unlock();
        }
    }
929682
function initializeSession(editor, previousEditor) {
            session = new Session(editor);
            ScopeManager.handleEditorChange(session, editor.document,
                previousEditor ? previousEditor.document : null);
            phProvider.setSession(session);
            cachedHints = null;
        }
750152
function persist (args) {
    // return original method call
    return this.model.createMeta({
        data: args,
        duplicate: true,
        responseIdOnly: true,
        session: this.session,
    })
}
192078
public void persistInSession( HttpServletRequest request, HttpServletResponse response )
    {
        PageFlowController currentPageFlow = PageFlowUtils.getCurrentPageFlow( request, getServletContext() );

        //
        // This code implicitly destroys the current page flow.  In order to prevent multiple threads
        // from executing inside the JPF at once, synchronize on it in order to complete the "destroy"
        // atomically.
        //
        if ( currentPageFlow != null && ! currentPageFlow.isOnNestingStack() )
        {
            synchronized ( currentPageFlow )
            {
                InternalUtils.setCurrentPageFlow( this, request, getServletContext() );
            }
        }
        //
        // Here, there is no previous page flow to syncyronize upon before destruction
        //
        else
        {
            InternalUtils.setCurrentPageFlow( this, request, getServletContext() );
        }
    }
929060
public void putPersistent(DbEntity e) {
    CachedDbEntity cachedDbEntity = new CachedDbEntity();
    cachedDbEntity.setEntity(e);
    cachedDbEntity.setEntityState(PERSISTENT);
    cachedDbEntity.determineEntityReferences();
    cachedDbEntity.makeCopy();

    putInternal(cachedDbEntity);
  }
358771
void commit() {
    long index = this.index;
    for (ServerSessionContext session : sessions.sessions.values()) {
      session.commit(index);
    }
  }
1083853
def save(self, commit=True):
        

        db.session.add(self)
        if commit:
            db.session.commit()
        return self
1288686
function(session) {
    this.session = session;
    this.doc = session.getDocument();

    this.clearSelection();
    this.selectionLead = this.doc.createAnchor(0, 0);
    this.selectionAnchor = this.doc.createAnchor(0, 0);

    var _self = this;
    this.selectionLead.on("change", function(e) {
        _self._emit("changeCursor");
        if (!_self.$isEmpty)
            _self._emit("changeSelection");
        if (!_self.$preventUpdateDesiredColumnOnChange && e.old.column != e.value.column)
            _self.$updateDesiredColumn();
    });

    this.selectionAnchor.on("change", function() {
        if (!_self.$isEmpty)
            _self._emit("changeSelection");
    });
}
27640
def _persist(self):
        """"""
        with open(self.file, 'w') as f:
            json.dump({
                'client': self.client,
                'creds': self.creds,
                'config': self.config
            }, f)
1283482
def bind(self, database):
        
        self._database = database

        while not self._sessions.full():
            session = self._new_session()
            session.create()
            self._sessions.put(session)
673861
public void saveAsEmpty(DbSession dbSession, String key) {
    checkKey(key);

    InternalPropertiesMapper mapper = getMapper(dbSession);
    mapper.deleteByKey(key);
    mapper.insertAsEmpty(key, system2.now());
  }
10644
function(key, value, delay){
            $ExpressSESSION.session.store[key] = value;
            if(delay && is_number(delay) && delay > 0){
                var vkey = self.id()+'_'+key;
                if($ExpressSESSION.session.expires[key]) clearTimeout(sesssion_expires[vkey]);
                sesssion_expires[vkey] = setTimeout(function(){
                    self.forget(key);
                    delete sesssion_expires[vkey];
                    delete $ExpressSESSION.session.expires[key];
                }, delay);
            }
        }