I've updated my local copy of NewGenerateMapBuilderTask.java so that it will
generate Peer classes with doUpdate(DOClass), doInsert(DOClass), and
buildCriteria(DOClass) methods (Jon, you'll recognize that I ripped this off
of the way you've written some peers in Scarab ;-).

I'd commit this myself, but I've lost my cvs password, and should probably
run this by the list anyway.

Here's the patch:

626c626,656
<             
---
> 
>             // Write the Insert(DO) Method
>             outFile.println( "    /** Method to do inserts */" );
>             outFile.println( "    public static Object doInsert( " + tableClassname 
>+ " obj ) throws Exception" );
>             outFile.println( "    {" );
>             outFile.println( "        return " + peerclassName + 
>".doInsert(buildCriteria(obj));" );
>             outFile.println( "    }" );
>             outFile.println( "" );
> 
>             // Write the buildCriteria Method
>             outFile.println( "    /** Build a Criteria object from the data object 
>for this peer */" );
>             outFile.println( "    public static Criteria buildCriteria( " + 
>tableClassname + " obj )" );
>             outFile.println( "    {" );
>             outFile.println( "        Criteria criteria = new Criteria();" );
>             for( j=0; j<columns.length; j++ )
>             {
>                 ColumnMap cmap = columns[j];
>                 String realColumnName = getColumnName(cmap.getColumnName());
>                 String shortColumnName = removeUnderScores(realColumnName);
>                 // this only supports integer primary keys right now
>                 if( cmap.isPrimaryKey() )
>                 {
>                     outFile.println( "        if( obj.get" + shortColumnName + "() > 
>0 )" );
>                     outFile.print( "    " );
>                 }
>                 outFile.println( "        criteria.add( " + peerclassName + "." + 
>realColumnName + ", obj.get" + shortColumnName + "() );" );
>             }
>             outFile.println( "        return criteria;" );
>             outFile.println( "    }" );
>             outFile.println( "" );
>                 
678a709,718
>             outFile.println( "" );
> 
>             // Write the Update(DO)
>             outFile.println( "    /**" );
>             outFile.println( "     * @param obj the data object to update in the 
>database." );
>             outFile.println( "     */" );
>             outFile.println( "    public static void doUpdate(" + tableClassname + " 
>obj) throws Exception" );
>             outFile.println( "    {" );
>             outFile.println( "        " + peerclassName + 
>".doUpdate(buildCriteria(obj));" );
>             outFile.println( "    }" );


------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to