com.onewebsql.query
Class UpdateQuery

java.lang.Object
  extended by com.onewebsql.query.WhereQuery
      extended by com.onewebsql.query.UpdateQuery
All Implemented Interfaces:
Expression

public class UpdateQuery
extends WhereQuery

Represents an UPDATE statement.


Field Summary
static String EQ
          Constant used to build a query.
static String EQ_QUESTION_MARK
          Constant used to build a query.
static String queryLexem
          Constant used to build a query.
static String SET
          Constant used to build a query.
protected  TableExpression table
          Table expression the statement modifies.
 
Fields inherited from class com.onewebsql.query.WhereQuery
where, WHERE
 
Fields inherited from interface com.onewebsql.query.Expression
COMMA, DOT, LB, QUESTION_MARK, RB, SPACE
 
Constructor Summary
UpdateQuery(TableExpression table)
          Constructor.
 
Method Summary
 void build(StringBuilder sb, String schemaName, List<Value> objs, DBAdapter adapter)
          Builds the text of the query (or a part of it) represented by this object.
protected  void checkColumn(Column c)
          Checks whether the table expresion of the query and the specified column are the same.
 boolean equals(Object obj)
           
 int hashCode()
           
 UpdateQuery set(Column column, Object value)
          Sets value for a single column.
 UpdateQuery set(Map<Column,?> vals)
          Sets values for updated columns in one go.
 String toString()
           
 
Methods inherited from class com.onewebsql.query.WhereQuery
getWhere, setWhere
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

queryLexem

public static final String queryLexem
Constant used to build a query.

See Also:
Constant Field Values

SET

public static final String SET
Constant used to build a query.

See Also:
Constant Field Values

EQ

public static final String EQ
Constant used to build a query.

See Also:
Constant Field Values

EQ_QUESTION_MARK

public static final String EQ_QUESTION_MARK
Constant used to build a query.

See Also:
Constant Field Values

table

protected TableExpression table
Table expression the statement modifies.

Constructor Detail

UpdateQuery

public UpdateQuery(TableExpression table)
Constructor.

Parameters:
table - table expression this UPDATE statement modifies
Method Detail

checkColumn

protected void checkColumn(Column c)
Checks whether the table expresion of the query and the specified column are the same.

Parameters:
c - column to be checked
Throws:
IllegalArgumentException - if the table expresion of the query and the specified column are not the same

set

public UpdateQuery set(Map<Column,?> vals)
Sets values for updated columns in one go.

Parameters:
vals - map representing columns to be updated; column is the key, its new value is the value
Returns:
modified query

set

public UpdateQuery set(Column column,
                       Object value)
Sets value for a single column.

Parameters:
column - column to be set
value - new value of the column
Returns:
modified query

build

public void build(StringBuilder sb,
                  String schemaName,
                  List<Value> objs,
                  DBAdapter adapter)
Description copied from interface: Expression
Builds the text of the query (or a part of it) represented by this object.

Parameters:
sb - StringBuilder to build the query text
schemaName - name of the database schema used to build the query
objs - an accumulator list to which query parameters are appended
adapter - database adapter which builds builds query in a way specific to the database engine

hashCode

public int hashCode()
Overrides:
hashCode in class WhereQuery

equals

public boolean equals(Object obj)
Overrides:
equals in class WhereQuery

toString

public String toString()
Overrides:
toString in class WhereQuery


Copyright © 2011-2013 e-point SA. All Rights Reserved.