public interface StatementsWriter extends Closeable
EntityStatements to a file or to the database.| Modifier and Type | Method and Description |
|---|---|
TableStatement |
createInsertStatement(GeneratorDialect dialect,
GeneratorTable table)
Creates a container for a dedicated "insert into table" statement.
|
EntityStatement |
createPlainStatement(GeneratorDialect dialect,
String sql)
Creates a container for a plain SQL statement, which is just executed "as is".
|
TableStatement |
createUpdateStatement(GeneratorDialect dialect,
GeneratorTable table,
GeneratorColumn idColumn,
ColumnExpression idValue)
Creates a container for a dedicated "update table" statement.
|
void |
flush()
Flushes any open statements.
|
default void |
truncateTables(GeneratorContext context)
Truncates all discovered tables before any data is written to that tables.
|
void |
writeComment(String comment)
Writes a SQL comment to the target.
|
default void |
writePlainStatement(GeneratorDialect dialect,
String sql)
Writes a plain SQL statement.
|
void |
writeSectionSeparator()
Writes a new line to the target file to separate different sections in the SQL file.
|
void |
writeStatement(EntityStatement statement)
Writes the given statement to a file or database.
|
TableStatement createInsertStatement(GeneratorDialect dialect, GeneratorTable table)
dialect - the current database dialecttable - the name of the tableEntityStatement createPlainStatement(GeneratorDialect dialect, String sql)
dialect - the current database dialectsql - the content of the sql statement (without any delimiter)TableStatement createUpdateStatement(GeneratorDialect dialect, GeneratorTable table, GeneratorColumn idColumn, ColumnExpression idValue)
dialect - the current database dialecttable - the name of the affected tableidColumn - the column that contains the id of the changed entityidValue - the expression for the id of the changed entityvoid flush()
throws IOException
IOException - if the target throws an exceptiondefault void truncateTables(GeneratorContext context)
context - the generator contextvoid writeComment(String comment) throws IOException
comment - the comment to writeIOException - if the target throws an exceptiondefault void writePlainStatement(GeneratorDialect dialect, String sql) throws IOException
writeStatement(createPlainStatement(sql), dialect).dialect - the current database dialectsql - the content of the SQL statementIOException - if the file or database throws an exceptionvoid writeSectionSeparator()
throws IOException
IOException - if the target throws such an exceptionvoid writeStatement(EntityStatement statement) throws IOException
statement - contains the values to writeIOException - if the file or database throws an exceptionCopyright © 2022 fastnate.org. All rights reserved.