public class Upsert extends MySqlPart
Generates an upsert statement for MySQL.
INSERT INTO `tableName` (`col1`, `col2`)
VALUES (val1, val2),
(val1, val2,
(val1, val2)
ON DUPLICATE KEY UPDATE `col1` = VALUES(`col1`), `col2` = VALUES(`col2`);
Modifier and Type | Method and Description |
---|---|
Upsert |
add(String columnName,
Object value) |
void |
collectSqlFragment(CodeWriter writer) |
InsertRow |
getLastRow() |
List<InsertRow> |
getRows() |
String |
getTable() |
Upsert |
nextRow() |
Upsert |
setPretty(boolean pretty)
Indicates if line breaks and indentations should be added to output upsert statement (default false).
Example output (pretty = true): INSERT INTO `tableName` (`col1`, `col2`) |
escapeKeyword, placeBackTicks
collectParameterValues, getParameterValues, getSqlFragment, isPretty, printSqlParts, toString
public Upsert(String table)
public Upsert setPretty(boolean pretty)
INSERT INTO `tableName` (`col1`, `col2`)
VALUES (val1, val2),
(val1, val2),
(val1, val2)
ON DUPLICATE KEY UPDATE `col1` = VALUES(`col1`), `col2` = VALUES(`col2`);
INSERT INTO `tableName` (`col1`, `col2`) VALUES (val1, val2), (val1, val2), (val1, val2) ON DUPLICATE KEY UPDATE `col1` = VALUES(`col1`), `col2` = VALUES(`col2`);
public String getTable()
public Upsert nextRow()
public InsertRow getLastRow()
public void collectSqlFragment(CodeWriter writer)
collectSqlFragment
in class SqlPart
Copyright (c) 2006-2024 North Concepts Inc. All Rights Reserved.