how lock method intended to use

23 views
Skip to first unread message

norber...@multimageweb.com

unread,
Mar 17, 2017, 4:54:09 AM3/17/17
to iDempiere
hi all,

we are trying understand how lock method can be and/or intended to use. (see code bellow)

example use case:  import bank statement and we need lock bank statement before start to create batch payments. Accidentally user start in 5 minutes twice same process and 2x250 payments were created. 

we want avoid similar cases. 
any known documentation pls ?
norbert


/**************************************************************************


   *   Lock it.


   *   @return true if locked


   */


  public boolean lock()


  {


    int index = get_ProcessingIndex();


    if (index != -1)


    {


      m_newValues[index] = Boolean.TRUE;    //  direct


      String sql = "UPDATE " + p_info.getTableName()


        + " SET Processing='Y' WHERE (Processing='N' OR Processing IS NULL) AND "


        + get_WhereClause(true);


      boolean success = false;


      if (isUseTimeoutForUpdate())


        success = DB.executeUpdateEx(sql, null, QUERY_TIME_OUT) == 1;  //  outside trx


      else


        success = DB.executeUpdate(sql, null) == 1;  //  outside trx


      if


        log.fine("success");


      else


        log.log(Level.WARNING, "failed");


      return success;


    }


    return false;


  }  //  lock



Reply all
Reply to author
Forward
0 new messages