public synchronized int update (Connection conn, T[] objects)
        throws SQLException
    {
        if (primaryKeys == null) {
            throw new IllegalStateException(
                "No primary key for table " + name + ".");
        }

        int nUpdated = 0;
        String sql = "update " + name + " set " + listOfAssignments +
            buildUpdateWhere();
        PreparedStatement updateStmt = conn.prepareStatement(sql);
        for (int i = 0; i < objects.length; i++) {
            int column = bindUpdateVariables(updateStmt, objects[i], null);
            for (int j = 0; j < primaryKeys.length; j++) {
                int fidx = primaryKeyIndices[j];
                fields[fidx].bindVariable(
                    updateStmt, objects[i], column+1+j);
            }
            updateStmt.addBatch();
        }
        int rc[] = updateStmt.executeBatch();
        for (int k = 0; k < rc.length; k++) {
            nUpdated += rc[k];
        }
        updateStmt.close();
        return nUpdated;
    }
public synchronized int update ( Connection conn , T [ ] objects ) throws SQLException { if ( primaryKeys == null ) { throw new IllegalStateException ( "No primary key for table " + name + "." ) ; } int nUpdated = 0 ; String sql = "update " + name + " set " + listOfAssignments + buildUpdateWhere ( ) ; PreparedStatement updateStmt = conn . prepareStatement ( sql ) ; for ( int i = 0 ; i < objects . length ; i ++ ) { int column = bindUpdateVariables ( updateStmt , objects [ i ] , null ) ; for ( int j = 0 ; j < primaryKeys . length ; j ++ ) { int fidx = primaryKeyIndices [ j ] ; fields [ fidx ] . bindVariable ( updateStmt , objects [ i ] , column + 1 + j ) ; } updateStmt . addBatch ( ) ; } int rc [ ] = updateStmt . executeBatch ( ) ; for ( int k = 0 ; k < rc . length ; k ++ ) { nUpdated += rc [ k ] ; } updateStmt . close ( ) ; return nUpdated ; }
Update set of records in the table using table's primary key to locate
record in the table and values of fields of objects from specified array
<I>objects</I> to alter record fields.

@param objects array of objects specifying primary keys and and new
values of updated record fields

@return number of objects actually updated