0 Replies Latest reply on Dec 12, 2003 9:29 AM by Jan Radl

    Optimistic locking and findByXXX

    Jan Radl Newbie

      Hi all,

      I have a one problem with optimistic locking (timestamp control) and findByXXX method.

      Situation :

      SSB with method

      public Tab03000Record[] getMLM_Brokers(Field id_master) {
      try {
      sLog.log(Priority.DEBUG, "getMLM_Brokers : begin ");
      ServiceLocator se = ServiceLocator.getInstance();
      Tab03000Home home = (Tab03000Home)se.getEjbLocalHome("Tab03000");
      ArrayList ar = null;
      try {
      if (FieldUtils.isNull(id_master)) {
      ar = new ArrayList(home.findByPrevIdNull());
      sLog.log(Priority.DEBUG, "getMLM_Brokers : null found");
      } else {
      ar = new ArrayList(home.findByPrevID(FieldUtils.getString(id_master)));
      sLog.log(Priority.DEBUG, "getMLM_Brokers : beans found for id_master=" + FieldUtils.getString(id_master) +"|");
      }
      } catch (FinderException ex) {
      sLog.log(Priority.DEBUG, "getMLM_Brokers : no beans found for id_master=" + FieldUtils.getString(id_master) +"|");
      }
      if (ar == null) {
      return (new Tab03000Record[0]);
      }
      Tab03000Record ret[] = new Tab03000Record[ar.size()];
      Tab03000Record tmp = EditOfPersUtils.createTab03000Record();
      for (int i = 0; i < ar.size(); i++) {
      ret = new Tab03000Record();
      if (!EJBUtils.ejb2Data((Tab03000)ar.get(i), ret
      , tmp)) {
      throw new Exception("Cannot convert bean data to struct");
      }
      }
      sLog.log(Priority.DEBUG, "getMLM_Brokers : return size=" + ret.length);
      return (ret);
      } catch (Exception ex) {
      sLog.log(Priority.FATAL, "getMLM_Brokers()", ex);
      throw new EJBException("Fatal Exception " + ex.getMessage());
      }
      }

      In server log I see this :

      2003-12-12 16:03:32,431 DEBUG [com.fss.eims.ejb.session.person.MLMBean] getMLM_Brokers : return size=1 2003-12-12 16:03:32,431 TRACE [org.jboss.ejb.plugins.TxInterceptorCMT] TxInterceptorCMT
      : In finally 2003-12-12 16:03:32,431 TRACE [org.jboss.ejb.plugins.StatefulSessionInstanceInterceptor] beforeCompletion called
      2003-12-12 16:03:32,431 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreEntityCommand.Tab03000] Executing SQL: UPDATE TAB03000 SET LAST_CHANGE=?, LV1_VALID_FROM=?, LV1_VALID_TO=? WHERE LV1_ID=? AND LAST_CHANGE=?
      2003-12-12 16:03:32,436 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCTimestampVersionFieldBridge.Tab03000#lastChange] Set parameter: index=1, jdbcType=TIMESTAMP, value=Fri Dec 12 16:03:32 CET 2003
      2003-12-12 16:03:32,436 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.Tab03000#lv1ValidFrom] Set parameter: index=2, jdbcType=DATE, value=2003-08-07 2003-12-12 16:03:32,436 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBrid
      ge.Tab03000#lv1ValidTo] Set parameter: index=3, jdbcType=DATE, value=2099-12-31 2003-12-12 16:03:32,436 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.Tab03000#lv1Id] Set parameter: index=4, jdbcType=VARCHAR, value=20030807092939641789
      2003-12-12 16:03:32,437 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCTimestampVersionFieldBridge.Tab03000#lastChange] Set parameter: index=5, jdbcType=TIMESTAMP, value=20
      03-12-12 15:48:08.933 2003-12-12 16:03:32,437 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreEntityCommand.Tab03000] Rows affected = 1

      I don't uderstand why JDBCStore was called because no setter mothod was invoked. This is problem for me because timestamp column is change after every invocation of this method.

      Is this correct ?

      Jan