1 Reply Latest reply on Sep 13, 2002 9:25 AM by richlin

    Modify JBoss3.0.2's source for speed up create relationship

    richlin Newbie

      Hi,
      i modify JBoss3.0.2's source for speed up the creating of relationship and it seem work...


      code is like:
      org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge
      {
      public void addRelation(EntityEnterpriseContext myCtx,
      Object fk) {
      ...

      FieldState tempFieldState = getFieldState(myCtx);//########Rich's modify
      if(tempFieldState.isLoaded())//########Rich's modify
      {//############Rich's modify
      load(myCtx);
      FieldState fieldState = getFieldState(myCtx);

      // Check that .....
      if(isSingleValued() && fieldState.getValue().size()
      > 0) {
      throw new IllegalStateException("This ...");
      }

      // must check to avoid dupes in the list
      if(fieldState.getValue().contains(fk)) {
      // we are already related to this entity
      return;
      }

      // add to current related set
      fieldState.getValue().add(fk);
      }//#####################Rich's modify

      // set the foreign key, if we have one.
      if(hasForeignKey()) {
      setForeignKey(myCtx, fk);
      }
      }
      }

      My modification is due to that JBoss is too slow when i add detail to a master which already have a lot of details.
      I dont need iterator the details in my creating transaction
      but JBoss will create the primarykey's Collection of all detail (maybe for synchronism)
      it take too much time

      so i modify the source
      In addRelation i will check relation collection isLoad()
      if not i dont need to add the collection again
      just set the foreign key

      i dont know if this is right
      have anyone give some reply or suggest..
      Thanks


      Rich
      PS.there is same problem in deleting Detail, i am trying to modify now...