public class EntitySqlGenerator extends Object implements Closeable
GeneratorDialect.| Constructor and Description |
|---|
EntitySqlGenerator(Writer writer)
Creates a new instance of this
EntitySqlGenerator. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Writes any missing SQL and closes the target writer.
|
protected <E> boolean |
findEntity(E entity)
Tries to find an entity in an online store.
|
<E> void |
markExistingEntities(Iterable<E> entities)
Marks a set of entity references, where we don't know the ID in the database.
|
<E> void |
markExistingEntity(E entity,
Number id)
Marks an entity reference, where we know the ID in the database.
|
<E> void |
write(E entity)
Creates the Import-SQL for an entity.
|
<E> void |
write(Iterable<? extends E> entities)
Creates the SQL for the given entities.
|
void |
writeAlignmentStatements()
Writes all statements that are necessary to align ID generators in the database with the current IDs.
|
void |
writeComment(String comment)
Writes a SQL comment to the associated writer.
|
protected void |
writeStatement(EntityStatement stmt)
Writes the given statement to the
writer. |
public EntitySqlGenerator(Writer writer)
EntitySqlGenerator.writer - the writer of the file to generatepublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOException - if the target writer throws oneprotected <E> boolean findEntity(E entity)
throws IOException
entity - the entity to checktrue if the entity was found and has an id nowIOException - if something wents wrongpublic <E> void markExistingEntities(Iterable<E> entities) throws IOException
entities - the entity to ignore during write(Object)IOException - if the writer throws onepublic <E> void markExistingEntity(E entity,
Number id)
markExistingEntities(Iterable), we know the id for the given entity.entity - the entity to ignore during write(Object)id - the id of the entity inpublic <E> void write(E entity)
throws IOException
entity - the entity to create the SQL forIOException - if the writer throws oneIllegalArgumentException - if the entity is invalidpublic <E> void write(Iterable<? extends E> entities) throws IOException
entities - the entities for SQL creationIOException - if the writer throws onepublic void writeAlignmentStatements()
throws IOException
IOException - if the target writer throws onepublic void writeComment(String comment) throws IOException
comment - the comment to writeIOException - if thew writer throws oneprotected void writeStatement(EntityStatement stmt) throws IOException
writer. May be overridden, if the statements should be written
somewhere else (e.g. directly into a database).stmt - the SQL statement to writeIOException - if the writer throws oneCopyright © 2016 fastnate.org. All rights reserved.