com.partnersoft.sql
Class SqlUpdater

java.lang.Object
  extended by com.partnersoft.sql.SqlUpdater

public class SqlUpdater
extends java.lang.Object

Tool to simplify basic key-type updates to an SqlTable.

The SQL generated is of the form "update TABLE set WHATNOT=?, NOTWHAT=? where THIS=? and THAT=? and..."; if you want anything more complex you should handle that yourself.

Creates and retains a prepared statement so you can hang onto it and use it over and over on the same connection for better performance.

Copyright 2008 Partner Software, Inc.

Version:
$Id$
Author:
Paul Reavis

Constructor Summary
SqlUpdater(SqlTable table)
           
SqlUpdater(SqlTable table, java.util.List<java.lang.String> columnNameList, java.util.List<java.lang.String> keyNameList)
           
 
Method Summary
 SqlTable getTable()
           
 void update(Cog record)
          Update a row using the given Cog of values to get the keys from.
 void update(java.util.List<java.lang.Object> values)
          Deletes a row with the given list of key values.
 void update(Naming<java.lang.Object> record)
          Update a row using the given Naming of values to get the values and keys from.
 void update(java.lang.Object... values)
          Update a row with the given array of key values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SqlUpdater

public SqlUpdater(SqlTable table)
           throws java.sql.SQLException
Throws:
java.sql.SQLException

SqlUpdater

public SqlUpdater(SqlTable table,
                  java.util.List<java.lang.String> columnNameList,
                  java.util.List<java.lang.String> keyNameList)
           throws java.sql.SQLException
Throws:
java.sql.SQLException
Method Detail

update

public void update(Naming<java.lang.Object> record)
            throws java.sql.SQLException
Update a row using the given Naming of values to get the values and keys from. These must have the same names as those given in the constructor.

Throws:
java.sql.SQLException

update

public void update(Cog record)
            throws java.sql.SQLException
Update a row using the given Cog of values to get the keys from. These must have the same names as those given in the constructor.

Throws:
java.sql.SQLException

update

public void update(java.lang.Object... values)
            throws java.sql.SQLException
Update a row with the given array of key values. These must have the same number and order as the columns given in the constructor; update values first, key values last.

Parameters:
values -
Throws:
java.sql.SQLException

update

public void update(java.util.List<java.lang.Object> values)
            throws java.sql.SQLException
Deletes a row with the given list of key values. These must have the same number and order as the key names given in the constructor.

Throws:
java.sql.SQLException

getTable

public SqlTable getTable()