• New Feature
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 3.3
    • Generator
    • None


      I've a small problem with the copy() and copyInto() methods in the generated Torque objects. I've tables with dependencies from other tables (for example a table "login" which has a foreign key to a table "address"). I want to use the BaseAddress.copy() method to copy the address object and save it. If I use this method, it also loads and copies internally all logins which are linked to the source address to the new address. So, it makes a deep copy.

      If the object "Address" has many hundreds related objects of "Login" this deep copy makes a lot that is sometimes not necessary. So, it's better to let the user/programmer decide if there program should do a deep copy or not.

      The best way would be, that there is a copy(boolean) method that should be added during BaseAddress generation. I think, it's not very complicated to add this "feature". Here is my proposal:

      1. add in Object.vm a new boolean parameter to copy() like this
      public $table.JavaName copy(boolean deepcopy) throws TorqueException
      return copyInto(new ${table.JavaName}(),deepcopy);
      2. create two new downwards compatible methods copy() and copyInto()
      public $table.JavaName copy() throws TorqueException

      { return copy(true); }

      protected $table.JavaName copyInto($table.JavaName copyObj) throws TorqueException

      { return copyInto(copyObject, true); }

      3. add a new parameter deepcopy to the old copyInto() method and check that variable before making the
      deepcopy. I think, it's not necessary to submit that value recursivly to the referers.
      protected $table.JavaName copyInto($table.JavaName copyObj, boolean) throws TorqueException
      #if ($complexObjectModel)
      if (deepcopy)

      { #foreach ($fk in $table.Referrers) ... #end }


      Maybe I can create a patch for you.


        1. patch.txt
          3 kB
          Thoralf Rickert



            tfischer Thomas Fox
            thoralf.rickert Thoralf Rickert
            0 Vote for this issue
            0 Start watching this issue