Package liquibase.change.core
Class LoadDataChange
java.lang.Object
liquibase.AbstractExtensibleObject
liquibase.plugin.AbstractPlugin
liquibase.change.AbstractChange
liquibase.change.AbstractTableChange
liquibase.change.core.LoadDataChange
- All Implemented Interfaces:
Cloneable,Change,ChangeWithColumns<LoadDataColumnConfig>,ExtensibleObject,Plugin,LiquibaseSerializable
- Direct Known Subclasses:
LoadUpdateDataChange
public class LoadDataChange
extends AbstractTableChange
implements ChangeWithColumns<LoadDataColumnConfig>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumprotected static classNested classes/interfaces inherited from interface liquibase.serializer.LiquibaseSerializable
LiquibaseSerializable.SerializationType -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Patternstatic final StringCSV Lines starting with that sign(s) will be treated as comments by defaultFields inherited from class liquibase.change.AbstractTableChange
catalogName, schemaName, tableNameFields inherited from class liquibase.change.AbstractChange
NODENAME_COLUMNFields inherited from interface liquibase.change.Change
EMPTY_CHANGE, SHOULD_EXECUTEFields inherited from interface liquibase.serializer.LiquibaseSerializable
GENERIC_CHANGELOG_EXTENSION_NAMESPACE, GENERIC_SNAPSHOT_EXTENSION_NAMESPACE, STANDARD_CHANGELOG_NAMESPACE, STANDARD_SNAPSHOT_NAMESPACEFields inherited from interface liquibase.plugin.Plugin
PRIORITY_DATABASE, PRIORITY_DEFAULT, PRIORITY_NOT_APPLICABLE, PRIORITY_SPECIALIZED -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddColumn(LoadDataColumnConfig column) Add a column configuration to the Change.checkStatus(Database database) Validate that this change executed successfully against the given database.protected LoadDataColumnConfigcolumnConfigFromName(String name, Integer idx) Get the column using the name, index or the headerprotected StringcolumnIdString(int index, LoadDataColumnConfig columnConfig) Returns a uniquestringfor the column for better identification.protected ExecutablePreparedStatementBasecreatePreparedStatement(Database database, String catalogName, String schemaName, String tableName, List<LoadDataColumnConfig> columns, ChangeSet changeSet, ResourceAccessor resourceAccessor) protected InsertStatementcreateStatement(String catalogName, String schemaName, String tableName) protected InsertSetStatementcreateStatementSet(String catalogName, String schemaName, String tableName) Implementation generates checksum by serializing the change withStringChangeLogSerializerbooleangenerateRollbackStatementsVolatile(Database database) Implementation delegates logic to theSqlGenerator.generateRollbackStatementsIsVolatile(Database)method on theSqlStatementobjects returned byChange.generateStatements(liquibase.database.Database)If no or null SqlStatements are returned by generateRollbackStatements then this method returns false.generateStatements(Database database) Generates theSqlStatementobjects required to run the change for the given database.protected SqlStatement[]generateStatementsFromRows(Database database, List<LoadDataChange.LoadDataRowConfig> rows) booleangenerateStatementsVolatile(Database database) Implementation delegates logic to theSqlGenerator.generateStatementsIsVolatile(Database)method on theSqlStatementobjects returned byChange.generateStatements(liquibase.database.Database).protected LoadDataColumnConfiggetColumnConfig(int index, String header) Return all theColumnConfigobjects defined for thisChangeConfirmation message to be displayed after the change is executed.getFile()protected Stringprotected static StringgetValueToWrite(Object value) Transform a value read from a CSV file into a string to be written into the database if the column type is not known.protected booleanprotected booleanisNullValue(String value, LoadDataColumnConfig column) voidsetColumns(List<LoadDataColumnConfig> columns) voidsetCommentLineStartsWith(String commentLineStartsWith) voidsetSeparator(String separator) booleanImplementation delegates logic to theSqlGenerator.supports(liquibase.statement.SqlStatement, liquibase.database.Database)method on theSqlStatementobjects returned byChange.generateStatements(liquibase.database.Database).protected booleansupportsBatchUpdates(Database database) Implementation checks the ChangeParameterMetaData for declared required fields and also delegates logic to theSqlGenerator.validate(liquibase.statement.SqlStatement, liquibase.database.Database, liquibase.sqlgenerator.SqlGeneratorChain)method on theSqlStatementobjects returned byChange.generateStatements(liquibase.database.Database).voidvalidateColumn(LoadDataColumnConfig columnConfig, ValidationErrors validationErrors, String columnIDString) protected ValidationErrorsvalidateColumns(ValidationErrors validationErrors) Validate all columns and collect errors in 'validationErrors'Implementation delegates logic to theSqlGenerator.warn(liquibase.statement.SqlStatement, liquibase.database.Database, liquibase.sqlgenerator.SqlGeneratorChain)method on theSqlStatementobjects returned byChange.generateStatements(liquibase.database.Database).Methods inherited from class liquibase.change.AbstractTableChange
getCatalogName, getSchemaNameMethods inherited from class liquibase.change.AbstractChange
createAlternateParameterNames, createChangeMetaData, createChangeParameterMetadata, createDescriptionMetaData, createEmptyColumnConfig, createExampleValueMetaData, createInverses, createMustEqualExistingMetaData, createRequiredDatabasesMetaData, createSerializationTypeMetaData, createSinceMetaData, createSupportedDatabasesMetaData, customLoadLogic, equals, finishInitialization, generateRollbackStatements, getAffectedDatabaseObjects, getChangeSet, getDescription, getExcludedFieldFilters, getResourceAccessor, getSerializableFieldNamespace, getSerializableFields, getSerializableFieldType, getSerializableFieldValue, getSerializedObjectName, hashCode, isInvalidProperty, load, modify, serialize, serializeValue, setChangeSet, setResourceAccessor, shouldExecuteChange, supportsRollback, toStringMethods inherited from class liquibase.AbstractExtensibleObject
clone, describe, get, get, get, getAttributes, getFieldValue, getObjectMetaData, getValuePath, has, setMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface liquibase.change.Change
shouldRunOnOsMethods inherited from interface liquibase.ExtensibleObject
clone, describe, get, get, getAttributes, getObjectMetaData, getValuePath, has, set
-
Field Details
-
DEFAULT_COMMENT_PATTERN
CSV Lines starting with that sign(s) will be treated as comments by default- See Also:
-
BASE64_PATTERN
-
-
Constructor Details
-
LoadDataChange
public LoadDataChange()
-
-
Method Details
-
getValueToWrite
Transform a value read from a CSV file into a string to be written into the database if the column type is not known.- Parameters:
value- the value to transform- Returns:
- if the value is empty or the string "NULL" (case-insensitive), return the empty string. If not, the value "toString()" representation (trimmed of spaces left and right) is returned.
-
hasPreparedStatementsImplemented
protected boolean hasPreparedStatementsImplemented() -
supports
Description copied from class:AbstractChangeImplementation delegates logic to theSqlGenerator.supports(liquibase.statement.SqlStatement, liquibase.database.Database)method on theSqlStatementobjects returned byChange.generateStatements(liquibase.database.Database). If no or null SqlStatements are returned by generateStatements then this method returns true. IfAbstractChange.generateStatementsVolatile(liquibase.database.Database)returns true, we cannot call generateStatements and so assume true.- Specified by:
supportsin interfaceChange- Overrides:
supportsin classAbstractChange
-
generateRollbackStatementsVolatile
Description copied from class:AbstractChangeImplementation delegates logic to theSqlGenerator.generateRollbackStatementsIsVolatile(Database)method on theSqlStatementobjects returned byChange.generateStatements(liquibase.database.Database)If no or null SqlStatements are returned by generateRollbackStatements then this method returns false.- Specified by:
generateRollbackStatementsVolatilein interfaceChange- Overrides:
generateRollbackStatementsVolatilein classAbstractChange
-
getTableName
- Overrides:
getTableNamein classAbstractTableChange
-
getFile
-
getUsePreparedStatements
-
getCommentLineStartsWith
-
setCommentLineStartsWith
-
isRelativeToChangelogFile
-
getEncoding
-
getSeparator
-
setSeparator
-
getQuotchar
-
addColumn
Description copied from interface:ChangeWithColumnsAdd a column configuration to the Change.- Specified by:
addColumnin interfaceChangeWithColumns<LoadDataColumnConfig>
-
getColumns
Description copied from interface:ChangeWithColumnsReturn all theColumnConfigobjects defined for thisChange- Specified by:
getColumnsin interfaceChangeWithColumns<LoadDataColumnConfig>
-
setColumns
- Specified by:
setColumnsin interfaceChangeWithColumns<LoadDataColumnConfig>
-
columnIdString
Returns a uniquestringfor the column for better identification. The returnedstringincludes the index of the column and, if available, its name.- Parameters:
index- the index of the columncolumnConfig- the column configuration- Returns:
- a string in the format " / column[index] (name:'columnName')" or " / column[index]" if the column name is not available.
-
validateColumns
Validate all columns and collect errors in 'validationErrors'- Parameters:
validationErrors- ValidationErrors to collect errors- Returns:
- validationErrors
-
generateStatements
Description copied from interface:ChangeGenerates theSqlStatementobjects required to run the change for the given database. NOTE: This method may be called multiple times throughout the changelog execution process and may be called in documentation generation and other integration points as well. If this method reads from the current database state or uses any other logic that will be affected by whether previous changeSets have ran or not, you must return true fromChange.generateStatementsVolatile(liquibase.database.Database).- Specified by:
generateStatementsin interfaceChange
-
supportsBatchUpdates
-
validate
Description copied from class:AbstractChangeImplementation checks the ChangeParameterMetaData for declared required fields and also delegates logic to theSqlGenerator.validate(liquibase.statement.SqlStatement, liquibase.database.Database, liquibase.sqlgenerator.SqlGeneratorChain)method on theSqlStatementobjects returned byChange.generateStatements(liquibase.database.Database). If no or null SqlStatements are returned by generateStatements then this method returns no errors. If there are no parameters than this method returns no errors- Specified by:
validatein interfaceChange- Overrides:
validatein classAbstractChange
-
validateColumn
public void validateColumn(LoadDataColumnConfig columnConfig, ValidationErrors validationErrors, String columnIDString) -
columnConfigFromName
Get the column using the name, index or the header- Parameters:
name- name or header of the column searchedidx- the index of the column searched- Returns:
- The column having the name or header equal to "name" or the index equal to idx or a new LoadDataColumnConfig if not found
-
generateStatementsVolatile
Description copied from class:AbstractChangeImplementation delegates logic to theSqlGenerator.generateStatementsIsVolatile(Database)method on theSqlStatementobjects returned byChange.generateStatements(liquibase.database.Database). If zero or null SqlStatements are returned by generateStatements then this method returns false.- Specified by:
generateStatementsVolatilein interfaceChange- Overrides:
generateStatementsVolatilein classAbstractChange
-
getCSVReader
- Throws:
IOExceptionLiquibaseException
-
getRelativeTo
-
createPreparedStatement
protected ExecutablePreparedStatementBase createPreparedStatement(Database database, String catalogName, String schemaName, String tableName, List<LoadDataColumnConfig> columns, ChangeSet changeSet, ResourceAccessor resourceAccessor) -
createStatement
-
createStatementSet
protected InsertSetStatement createStatementSet(String catalogName, String schemaName, String tableName) -
getColumnConfig
-
checkStatus
Description copied from interface:ChangeValidate that this change executed successfully against the given database. This will check that the update completed at a high level plus check details of the change. For example, a change to add a column will check that the column exists plus data type, default values, etc.- Specified by:
checkStatusin interfaceChange- Overrides:
checkStatusin classAbstractChange
-
getConfirmationMessage
Description copied from interface:ChangeConfirmation message to be displayed after the change is executed. Should include relevant configuration settings to make it as helpful as possible. This method may be called outside the changelog execution process, such as in documentation generation.- Specified by:
getConfirmationMessagein interfaceChange
-
generateCheckSum
Description copied from class:AbstractChangeImplementation generates checksum by serializing the change withStringChangeLogSerializer- Specified by:
generateCheckSumin interfaceChange- Overrides:
generateCheckSumin classAbstractChange
-
warn
Description copied from class:AbstractChangeImplementation delegates logic to theSqlGenerator.warn(liquibase.statement.SqlStatement, liquibase.database.Database, liquibase.sqlgenerator.SqlGeneratorChain)method on theSqlStatementobjects returned byChange.generateStatements(liquibase.database.Database). If a generated statement is not supported for the given database, no warning will be added since that is a validation error. If no or null SqlStatements are returned by generateStatements then this method returns no warnings.- Specified by:
warnin interfaceChange- Overrides:
warnin classAbstractChange
-
getSerializedObjectNamespace
- Specified by:
getSerializedObjectNamespacein interfaceLiquibaseSerializable- Overrides:
getSerializedObjectNamespacein classAbstractChange
-
generateStatementsFromRows
protected SqlStatement[] generateStatementsFromRows(Database database, List<LoadDataChange.LoadDataRowConfig> rows) -
isNullValue
-