mpoeschl    2002/11/15 04:53:02

  Modified:    src/templates/om Peer.vm
  Log:
  TRQ24: add doDelete(ObjectKey pk) methods
  
  Revision  Changes    Path
  1.44      +43 -13    jakarta-turbine-torque/src/templates/om/Peer.vm
  
  Index: Peer.vm
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/templates/om/Peer.vm,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- Peer.vm   24 Oct 2002 20:27:09 -0000      1.43
  +++ Peer.vm   15 Nov 2002 12:53:02 -0000      1.44
  @@ -816,6 +816,48 @@
           doDelete(buildCriteria(obj), con);
       }
   
  +    /**
  +     * Method to do deletes.
  +     *
  +     * @param pk ObjectKey that is used DELETE from database.
  +     */
  +    public static void doDelete(ObjectKey pk) throws TorqueException
  +    {
  +        $basePrefix${table.JavaName}Peer
  +           .doDelete(pk, (Connection) null);
  +    }
  +
  +    /**
  +     * Method to delete.  This method is to be used during a transaction,
  +     * otherwise use the doDelete(ObjectKey) method.  It will take
  +     * care of the connection details internally.
  +     *
  +     * @param pk the primary key for the object to delete in the database.
  +     */
  +    public static void doDelete(ObjectKey pk, Connection con)
  +        throws TorqueException
  +    {
  +        doDelete(buildCriteria(pk), con);
  +    }
  +
  +    /** Build a Criteria object from an ObjectKey */
  +    public static Criteria buildCriteria( ObjectKey pk )
  +    {
  +        Criteria criteria = new Criteria();
  +  #if ($table.PrimaryKeys.size() == 1)
  +            criteria.add($table.PrimaryKeys.get(0).Name.toUpperCase(), pk);
  +  #else
  +        SimpleKey[] keys = (SimpleKey[])pk.getValue();
  +    #set ( $i = 0 )
  +    #foreach ($col in $table.PrimaryKeys)
  +        #set ( $cup=$col.Name.toUpperCase() )
  +            criteria.add($cup, keys[$i]);
  +        #set ( $i = $i + 1 )
  +    #end
  +  #end
  +        return criteria;
  +     }
  +    
       /** Build a Criteria object from the data object for this peer */
       public static Criteria buildCriteria( $table.JavaName obj )
       {
  @@ -887,19 +929,7 @@
       public static $table.JavaName ${retrieveMethod}(ObjectKey pk, Connection con)
           throws TorqueException
       {
  -
  -        Criteria criteria = new Criteria();
  -  #if ($table.PrimaryKeys.size() == 1)
  -            criteria.add($table.PrimaryKeys.get(0).Name.toUpperCase(), pk);
  -  #else
  -        SimpleKey[] keys = (SimpleKey[])pk.getValue();
  -    #set ( $i = 0 )
  -    #foreach ($col in $table.PrimaryKeys)
  -        #set ( $cup=$col.Name.toUpperCase() )
  -            criteria.add($cup, keys[$i]);
  -        #set ( $i = $i + 1 )
  -    #end
  -  #end
  +        Criteria criteria = buildCriteria(pk);
           List v = doSelect(criteria, con);
           if (v.size() != 1)
           {
  
  
  

--
To unsubscribe, e-mail:   <mailto:turbine-torque-dev-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:turbine-torque-dev-help@;jakarta.apache.org>

Reply via email to