|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.ninja_squad.dbsetup.operation.Insert
@Immutable public final class Insert
Operation which inserts one or several rows into a table. Example usage:
Insert insert = Insert.into("CLIENT") .columns("CLIENT_ID", "FIRST_NAME", "LAST_NAME", "DATE_OF_BIRTH", "CLIENT_TYPE") .values(1L, "John", "Doe", "1975-07-19", ClientType.NORMAL) .values(2L, "Jack", "Smith", "1969-08-22", ClientType.HIGH_PRIORITY) .withDefaultValue("DELETED", false) .withDefaultValue("VERSION", 1) .withBinder(new ClientTypeBinder(), "CLIENT_TYPE") .build();The above operation will insert two rows inside the CLIENT table. For each row, the column DELETED will be set to
false
and the column VERSION will be set to 1. For the column CLIENT_TYPE, instead of using the
Binder
associated to the type of the column found in the metadata of the table, a custom binder will be used.
Nested Class Summary | |
---|---|
static class |
Insert.Builder
A builder used to create an Insert operation. |
Method Summary | |
---|---|
boolean |
equals(java.lang.Object obj)
|
void |
execute(java.sql.Connection connection,
BinderConfiguration configuration)
Inserts the values and generated values in the table. |
int |
hashCode()
|
static Insert.Builder |
into(java.lang.String table)
Creates a new Builder instance, in order to build an Insert operation into the given table |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public void execute(java.sql.Connection connection, BinderConfiguration configuration) throws java.sql.SQLException
useMetadata
has been set to
false
, the given configuration is used to get the appropriate binder. Nevertheless, if a binder
has explicitely been associated to a given column, this binder will always be used for this column.
execute
in interface Operation
connection
- the connection used to execute the operationconfiguration
- the binder configuration, used to get appropriate binders based on the metadata of
the prepared statements
java.sql.SQLException
- if the execution throws a SQLExceptionpublic java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public static Insert.Builder into(@Nonnull java.lang.String table)
table
- the name of the table to insert into
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |