Interface StatementsWriter
- All Superinterfaces:
AutoCloseable,Closeable
- All Known Implementing Classes:
AbstractStatementsWriter,ConnectedStatementsWriter,FileStatementsWriter,LiquibaseStatementsWriter,ListStatementsWriter,PostgreSqlBulkWriter
Responsible to write
EntityStatements to a file or to the database.- Author:
- Tobias Liefke
-
Method Summary
Modifier and TypeMethodDescriptioncreateInsertStatement(GeneratorDialect dialect, GeneratorTable table) Creates a container for a dedicated "insert into table" statement.createPlainStatement(GeneratorDialect dialect, String sql) Creates a container for a plain SQL statement, which is just executed "as is".createUpdateStatement(GeneratorDialect dialect, GeneratorTable table, GeneratorColumn idColumn, ColumnExpression idValue) Creates a container for a dedicated "update table" statement.voidflush()Flushes any open statements.default voidtruncateTables(GeneratorContext context) Truncates all discovered tables before any data is written to that tables.voidwriteComment(String comment) Writes a SQL comment to the target.default voidwritePlainStatement(GeneratorDialect dialect, String sql) Writes a plain SQL statement.voidWrites a new line to the target file to separate different sections in the SQL file.voidwriteStatement(EntityStatement statement) Writes the given statement to a file or database.
-
Method Details
-
createInsertStatement
Creates a container for a dedicated "insert into table" statement.- Parameters:
dialect- the current database dialecttable- the name of the table- Returns:
- the created statement
-
createPlainStatement
Creates a container for a plain SQL statement, which is just executed "as is".- Parameters:
dialect- the current database dialectsql- the content of the sql statement (without any delimiter)- Returns:
- the created statement
-
createUpdateStatement
TableStatement createUpdateStatement(GeneratorDialect dialect, GeneratorTable table, GeneratorColumn idColumn, ColumnExpression idValue) Creates a container for a dedicated "update table" statement.- Parameters:
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 entity- Returns:
- the created statement
-
flush
Flushes any open statements.- Throws:
IOException- if the target throws an exception
-
truncateTables
Truncates all discovered tables before any data is written to that tables.- Parameters:
context- the generator context
-
writeComment
Writes a SQL comment to the target.- Parameters:
comment- the comment to write- Throws:
IOException- if the target throws an exception
-
writePlainStatement
Writes a plain SQL statement. Shortcut forwriteStatement(createPlainStatement(sql), dialect).- Parameters:
dialect- the current database dialectsql- the content of the SQL statement- Throws:
IOException- if the file or database throws an exception
-
writeSectionSeparator
Writes a new line to the target file to separate different sections in the SQL file.- Throws:
IOException- if the target throws such an exception
-
writeStatement
Writes the given statement to a file or database.- Parameters:
statement- contains the values to write- Throws:
IOException- if the file or database throws an exception
-