Class AbstractStatementsWriter
java.lang.Object
org.fastnate.generator.statements.AbstractStatementsWriter
- All Implemented Interfaces:
Closeable,AutoCloseable,StatementsWriter
- Direct Known Subclasses:
ConnectedStatementsWriter,FileStatementsWriter,LiquibaseStatementsWriter,ListStatementsWriter
Base class for implementations of
StatementsWriter.- Author:
- Tobias Liefke
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classBase class for insert and update statements.protected static classHolds the information for an SQL Insert statement.protected static classA single (unparsed) SQL statement.protected static classHolds the information for an SQL update statement. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()createInsertStatement(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.voidwriteComment(String comment) Writes a SQL comment to the target.voidWrites a new line to the target file to separate different sections in the SQL file.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.fastnate.generator.statements.StatementsWriter
truncateTables, writePlainStatement, writeStatement
-
Constructor Details
-
AbstractStatementsWriter
public AbstractStatementsWriter()
-
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
createInsertStatement
Description copied from interface:StatementsWriterCreates a container for a dedicated "insert into table" statement.- Specified by:
createInsertStatementin interfaceStatementsWriter- Parameters:
dialect- the current database dialecttable- the name of the table- Returns:
- the created statement
-
createPlainStatement
Description copied from interface:StatementsWriterCreates a container for a plain SQL statement, which is just executed "as is".- Specified by:
createPlainStatementin interfaceStatementsWriter- Parameters:
dialect- the current database dialectsql- the content of the sql statement (without any delimiter)- Returns:
- the created statement
-
createUpdateStatement
public TableStatement createUpdateStatement(GeneratorDialect dialect, GeneratorTable table, GeneratorColumn idColumn, ColumnExpression idValue) Description copied from interface:StatementsWriterCreates a container for a dedicated "update table" statement.- Specified by:
createUpdateStatementin interfaceStatementsWriter- 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
Description copied from interface:StatementsWriterFlushes any open statements.- Specified by:
flushin interfaceStatementsWriter- Throws:
IOException- if the target throws an exception
-
writeComment
Description copied from interface:StatementsWriterWrites a SQL comment to the target.- Specified by:
writeCommentin interfaceStatementsWriter- Parameters:
comment- the comment to write- Throws:
IOException- if the target throws an exception
-
writeSectionSeparator
Description copied from interface:StatementsWriterWrites a new line to the target file to separate different sections in the SQL file.- Specified by:
writeSectionSeparatorin interfaceStatementsWriter- Throws:
IOException- if the target throws such an exception
-