com.mysema.query.sql.dml
Class SQLInsertClause

java.lang.Object
  extended by com.mysema.query.sql.dml.AbstractSQLClause
      extended by com.mysema.query.sql.dml.SQLInsertClause
All Implemented Interfaces:
DMLClause<SQLInsertClause>, InsertClause<SQLInsertClause>, StoreClause<SQLInsertClause>
Direct Known Subclasses:
MySQLReplaceClause

public class SQLInsertClause
extends AbstractSQLClause
implements InsertClause<SQLInsertClause>

SQLInsertClause defines an INSERT INTO clause

Author:
tiwe

Field Summary
 
Fields inherited from class com.mysema.query.sql.dml.AbstractSQLClause
configuration
 
Constructor Summary
SQLInsertClause(Connection connection, Configuration configuration, RelationalPath<?> entity)
           
SQLInsertClause(Connection connection, Configuration configuration, RelationalPath<?> entity, AbstractSQLSubQuery<?> subQuery)
           
SQLInsertClause(Connection connection, SQLTemplates templates, RelationalPath<?> entity)
           
SQLInsertClause(Connection connection, SQLTemplates templates, RelationalPath<?> entity, AbstractSQLSubQuery<?> subQuery)
           
 
Method Summary
 SQLInsertClause addBatch()
          Add the current state of bindings as a batch item
 SQLInsertClause addFlag(QueryFlag.Position position, String flag)
          Add the given String literal at the given position as a query flag
 SQLInsertClause columns(Path<?>... columns)
          Define the columns to be populated
 long execute()
          Execute the clause and return the amount of affected rows
<T> T
executeWithKey(Path<T> path)
          Execute the clause and return the generated key with the type of the given path If no rows were created, null is returned, otherwise the key of the first row is returned.
 ResultSet executeWithKeys()
          Execute the clause and return the generated keys as a ResultSet
<T> List<T>
executeWithKeys(Path<T> path)
          Execute the clause and return the generated keys with the type of the given path.
 SQLInsertClause populate(Object bean)
          Populate the INSERT clause with the properties of the given bean.
 SQLInsertClause select(SubQueryExpression<?> sq)
          Define the populate via subquery
<T> SQLInsertClause
set(Path<T> path, Expression<? extends T> expression)
          Add an expression binding
<T> SQLInsertClause
set(Path<T> path, T value)
          Add a value binding
<T> SQLInsertClause
setNull(Path<T> path)
          Bind the given path to null
 String toString()
           
 SQLInsertClause values(Object... v)
          Define the value bindings
 
Methods inherited from class com.mysema.query.sql.dml.AbstractSQLClause
close, close, setParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SQLInsertClause

public SQLInsertClause(Connection connection,
                       SQLTemplates templates,
                       RelationalPath<?> entity)

SQLInsertClause

public SQLInsertClause(Connection connection,
                       SQLTemplates templates,
                       RelationalPath<?> entity,
                       AbstractSQLSubQuery<?> subQuery)

SQLInsertClause

public SQLInsertClause(Connection connection,
                       Configuration configuration,
                       RelationalPath<?> entity,
                       AbstractSQLSubQuery<?> subQuery)

SQLInsertClause

public SQLInsertClause(Connection connection,
                       Configuration configuration,
                       RelationalPath<?> entity)
Method Detail

addFlag

public SQLInsertClause addFlag(QueryFlag.Position position,
                               String flag)
Add the given String literal at the given position as a query flag

Parameters:
position -
flag -
Returns:

addBatch

public SQLInsertClause addBatch()
Add the current state of bindings as a batch item

Returns:

columns

public SQLInsertClause columns(Path<?>... columns)
Description copied from interface: InsertClause
Define the columns to be populated

Specified by:
columns in interface InsertClause<SQLInsertClause>
Returns:

executeWithKey

@Nullable
public <T> T executeWithKey(Path<T> path)
Execute the clause and return the generated key with the type of the given path If no rows were created, null is returned, otherwise the key of the first row is returned.

Type Parameters:
T -
Parameters:
path -
Returns:

executeWithKeys

public <T> List<T> executeWithKeys(Path<T> path)
Execute the clause and return the generated keys with the type of the given path. If now rows were created and empty list is returned.

Type Parameters:
T -
Parameters:
path -
Returns:

executeWithKeys

public ResultSet executeWithKeys()
Execute the clause and return the generated keys as a ResultSet

Returns:

execute

public long execute()
Description copied from interface: DMLClause
Execute the clause and return the amount of affected rows

Specified by:
execute in interface DMLClause<SQLInsertClause>
Returns:

select

public SQLInsertClause select(SubQueryExpression<?> sq)
Description copied from interface: InsertClause
Define the populate via subquery

Specified by:
select in interface InsertClause<SQLInsertClause>
Returns:

set

public <T> SQLInsertClause set(Path<T> path,
                               T value)
Description copied from interface: StoreClause
Add a value binding

Specified by:
set in interface StoreClause<SQLInsertClause>
Parameters:
path - path to be updated
value - value to set
Returns:

set

public <T> SQLInsertClause set(Path<T> path,
                               Expression<? extends T> expression)
Description copied from interface: StoreClause
Add an expression binding

Specified by:
set in interface StoreClause<SQLInsertClause>
Returns:

setNull

public <T> SQLInsertClause setNull(Path<T> path)
Description copied from interface: StoreClause
Bind the given path to null

Specified by:
setNull in interface StoreClause<SQLInsertClause>
Returns:

values

public SQLInsertClause values(Object... v)
Description copied from interface: InsertClause
Define the value bindings

Specified by:
values in interface InsertClause<SQLInsertClause>
Returns:

toString

public String toString()
Overrides:
toString in class Object

populate

public SQLInsertClause populate(Object bean)
Populate the INSERT clause with the properties of the given bean. The properties need to match the fields of the clause's entity instance.

Parameters:
bean -
Returns:


Copyright © 2007-2011 Mysema Ltd. All Rights Reserved.