com.onewebsql.query
Class InsertQuery

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

public class InsertQuery
extends Object
implements Expression

Represents an INSERT query.


Field Summary
static String INTO
          Constant used to build a query.
static String queryLexem
          Constant used to build a query.
static String QUESTION_MARK
          Constant used to build a query.
protected  TableExpression table
          Table expression for which this query was created.
static String VALUES
          Constant used to build a query.
 
Fields inherited from interface com.onewebsql.query.Expression
COMMA, DOT, LB, RB, SPACE
 
Constructor Summary
InsertQuery(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 of this query and the specified column are the same.
 InsertQuery set(Column column, Object value)
          Sets the value of a single column.
 InsertQuery values(Map<Column,Object> vals)
          Sets the values of the inserted tuple.
 InsertQuery values(SelectQuery query)
          Marks this query as INSERT INTO sth SELECT ...
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

queryLexem

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

See Also:
Constant Field Values

INTO

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

See Also:
Constant Field Values

VALUES

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

See Also:
Constant Field Values

QUESTION_MARK

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

See Also:
Constant Field Values

table

protected TableExpression table
Table expression for which this query was created.

Constructor Detail

InsertQuery

public InsertQuery(TableExpression table)
Constructor.

Parameters:
table - table expression this query inserts into
Method Detail

checkColumn

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

Parameters:
c - column to check
Throws:
IllegalArgumentException - if the table of this query and the specified column are not the same

values

public InsertQuery values(Map<Column,Object> vals)
Sets the values of the inserted tuple.

Parameters:
vals - map where (Column) objects are keys, and the inserted values are values
Returns:
this query with inserted values set

values

public InsertQuery values(SelectQuery query)
Marks this query as INSERT INTO sth SELECT ... type of query. Sets the SELECT query to be used in the INSERT query.

Parameters:
query - SELECT query
Returns:
this query marked as INSERT INTO sth SELECT ... type of query

set

public InsertQuery set(Column column,
                       Object value)
Sets the value of a single column.

Parameters:
column - column to be set
value - value to be set
Returns:
this query this the value of a single column set

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.

Specified by:
build in interface Expression
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


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