org.jooq
Interface InsertQuery<R extends Record>

Type Parameters:
R - The record type of the table being inserted into
All Superinterfaces:
Adapter, Attachable, Insert<R>, Query, QueryPart, Serializable, StoreQuery<R>

public interface InsertQuery<R extends Record>
extends StoreQuery<R>, Insert<R>

A query for data insertion

Author:
Lukas Eder

Method Summary
 void addRecord(R record)
          Short for calling newRecord(); setRecord(record);
<T> void
addValueForUpdate(Field<T> field, Field<T> value)
          Add a value to the ON DUPLICATE KEY UPDATE clause of this INSERT statement, where this is supported.
<T> void
addValueForUpdate(Field<T> field, T value)
          Add a value to the ON DUPLICATE KEY UPDATE clause of this INSERT statement, where this is supported.
 void addValuesForUpdate(Map<? extends Field<?>,?> map)
          Add multiple values to the ON DUPLICATE KEY UPDATE clause of this INSERT statement, where this is supported.
 R getReturnedRecord()
          The record holding returned values as specified by any of the setReturning() methods.
 Result<R> getReturnedRecords()
          The records holding returned values as specified by any of the setReturning() methods.
 void newRecord()
          Adds a new Record to the insert statement for multi-record inserts Calling this method will cause subsequent calls to StoreQuery.addValue(Field, Object) (and similar) to fill the next record.
 void onDuplicateKeyUpdate(boolean flag)
          Whether a ON DUPLICATE KEY UPDATE clause should be added to this INSERT statement.
 void setReturning()
          Configure the INSERT statement to return all fields in R.
 void setReturning(Collection<? extends Field<?>> fields)
          Configure the INSERT statement to return a list of fields in R.
 void setReturning(Field<?>... fields)
          Configure the INSERT statement to return a list of fields in R.
 void setReturning(Identity<R,? extends Number> identity)
          Configure the INSERT statement to return the generated identity value.
 
Methods inherited from interface org.jooq.StoreQuery
addValue, addValue, addValueAsArray, addValueAsArray, addValues, setRecord
 
Methods inherited from interface org.jooq.Query
bind, bind, execute, getBindValues, getParam, getParams, getSQL, getSQL
 
Methods inherited from interface org.jooq.Attachable
attach
 
Methods inherited from interface org.jooq.Adapter
internalAPI
 

Method Detail

newRecord

void newRecord()
Adds a new Record to the insert statement for multi-record inserts

Calling this method will cause subsequent calls to StoreQuery.addValue(Field, Object) (and similar) to fill the next record.

If this call is not followed by StoreQuery.addValue(Field, Object) calls, then this call has no effect.

If this call is done on a fresh insert statement (without any values yet), then this call has no effect either.


addRecord

void addRecord(R record)
Short for calling newRecord(); setRecord(record);

Parameters:
record - The record to add to this insert statement.

onDuplicateKeyUpdate

void onDuplicateKeyUpdate(boolean flag)
Whether a ON DUPLICATE KEY UPDATE clause should be added to this INSERT statement.

See Also:
InsertOnDuplicateStep.onDuplicateKeyUpdate()

addValueForUpdate

<T> void addValueForUpdate(Field<T> field,
                           T value)
Add a value to the ON DUPLICATE KEY UPDATE clause of this INSERT statement, where this is supported.

See Also:
InsertOnDuplicateStep.onDuplicateKeyUpdate()

addValueForUpdate

<T> void addValueForUpdate(Field<T> field,
                           Field<T> value)
Add a value to the ON DUPLICATE KEY UPDATE clause of this INSERT statement, where this is supported.

See Also:
InsertOnDuplicateStep.onDuplicateKeyUpdate()

addValuesForUpdate

void addValuesForUpdate(Map<? extends Field<?>,?> map)
Add multiple values to the ON DUPLICATE KEY UPDATE clause of this INSERT statement, where this is supported.

Please assure that key/value pairs have matching <T> types. Values can either be of type <T> or Field<T>

See Also:
InsertOnDuplicateStep.onDuplicateKeyUpdate()

setReturning

void setReturning()
Configure the INSERT statement to return all fields in R.

See Also:
getReturnedRecords()

setReturning

void setReturning(Identity<R,? extends Number> identity)
Configure the INSERT statement to return the generated identity value.

Parameters:
identity - The table's identity
See Also:
getReturnedRecords()

setReturning

void setReturning(Field<?>... fields)
Configure the INSERT statement to return a list of fields in R.

Parameters:
fields - Fields to be returned
See Also:
getReturnedRecords()

setReturning

void setReturning(Collection<? extends Field<?>> fields)
Configure the INSERT statement to return a list of fields in R.

Parameters:
fields - Fields to be returned
See Also:
getReturnedRecords()

getReturnedRecord

R getReturnedRecord()
The record holding returned values as specified by any of the setReturning() methods.

If the insert statement returns several records, this is the same as calling getReturnedRecords().get(0)

This implemented differently for every dialect:

See Also:
getReturnedRecords()

getReturnedRecords

Result<R> getReturnedRecords()
The records holding returned values as specified by any of the setReturning() methods.

This implemented differently for every dialect:

This currently only works well for DB2, HSQLDB, MySQL, and Postgres



Copyright © 2012. All Rights Reserved.