Class AbstractDatabaseWriter
java.lang.Object
org.jumpmind.symmetric.io.data.writer.AbstractDatabaseWriter
- All Implemented Interfaces:
IDataResource
,IDataWriter
- Direct Known Subclasses:
AbstractDatabaseWriterTest.StubAbstractDatabaseWriter
,DefaultDatabaseWriter
,HbaseDatabaseWriter
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Batch
static final String
static final String
protected IDatabaseWriterConflictResolver
protected DataContext
protected boolean
protected boolean
protected CsvData
protected boolean
protected Table
protected Map<Batch,
Statistics> protected Map<String,
TableColumnSourceReferences> protected Table
static final String
protected long
protected DatabaseWriterSettings
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractDatabaseWriter
(DatabaseWriterSettings settings) AbstractDatabaseWriter
(IDatabaseWriterConflictResolver conflictResolver, DatabaseWriterSettings settings) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
allowInsertIntoAutoIncrementColumns
(boolean value, Table table) protected void
bindVariables
(Map<String, Object> variables) protected TableColumnSourceReferences
Builds new column mappings and saves it to the cache.protected void
protected void
Clears column mapping cache.void
close()
protected void
commit
(boolean earlyCommit) protected abstract boolean
protected abstract AbstractDatabaseWriter.LoadStatus
void
void
protected void
filterAfter
(CsvData data) protected boolean
filterBefore
(CsvData data) protected boolean
filterError
(CsvData data, Exception ex) getBatch()
getLookupDataMap
(CsvData data, Conflict conflict) protected String
getPkDataFor
(CsvData data, Column column) protected String[]
getRowData
(CsvData data, String dataType) Parses source data and returns string array with values in same positions as target columns.protected TableColumnSourceReferences
Looks up column mappings in the cache (or generates them).protected boolean
protected abstract AbstractDatabaseWriter.LoadStatus
protected abstract void
logFailureDetails
(Throwable e, CsvData data, boolean logLastDmlDetails) protected abstract void
logFailureDetails
(Throwable e, CsvData data, boolean logLastDmlDetails, Object[] values) protected Table
lookupTableAtTarget
(Table sourceTable) protected void
protected void
protected void
protected void
void
open
(DataContext context) protected void
Verifies that column mapping cache is up-to date.protected void
rollback()
protected boolean
void
setConflictResolver
(IDatabaseWriterConflictResolver conflictResolver) protected abstract boolean
boolean
void
protected void
targetTableWasChangedByFilter
(Table oldTargetTable) protected abstract AbstractDatabaseWriter.LoadStatus
void
-
Field Details
-
CONFLICT_ERROR
- See Also:
-
TRANSACTION_ABORTED
- See Also:
-
CONFLICT_IGNORE
- See Also:
-
lastUseConflictDetection
protected boolean lastUseConflictDetection -
lastApplyChangesOnly
protected boolean lastApplyChangesOnly -
isRequiresSavePointsInTransaction
protected boolean isRequiresSavePointsInTransaction -
sourceTable
-
targetTable
-
targetTables
-
lastData
-
batch
-
context
-
uncommittedCount
protected long uncommittedCount -
writerSettings
-
statistics
-
conflictResolver
-
missingTables
-
targetColumnSourceReferencesMap
-
-
Constructor Details
-
AbstractDatabaseWriter
public AbstractDatabaseWriter() -
AbstractDatabaseWriter
-
AbstractDatabaseWriter
public AbstractDatabaseWriter(IDatabaseWriterConflictResolver conflictResolver, DatabaseWriterSettings settings)
-
-
Method Details
-
open
- Specified by:
open
in interfaceIDataResource
-
start
- Specified by:
start
in interfaceIDataWriter
-
start
- Specified by:
start
in interfaceIDataWriter
-
write
- Specified by:
write
in interfaceIDataWriter
-
checkForEarlyCommit
protected void checkForEarlyCommit() -
commit
protected void commit(boolean earlyCommit) -
rollback
protected void rollback() -
filterError
-
filterBefore
-
targetTableWasChangedByFilter
-
notifyFiltersEarlyCommit
protected void notifyFiltersEarlyCommit() -
notifyFiltersBatchComplete
protected void notifyFiltersBatchComplete() -
notifyFiltersBatchCommitted
protected void notifyFiltersBatchCommitted() -
notifyFiltersBatchRolledback
protected void notifyFiltersBatchRolledback() -
filterAfter
-
insert
-
delete
protected abstract AbstractDatabaseWriter.LoadStatus delete(CsvData data, boolean useConflictDetection) -
update
protected abstract AbstractDatabaseWriter.LoadStatus update(CsvData data, boolean applyChangesOnly, boolean useConflictDetection) -
create
-
sql
-
logFailureDetails
-
logFailureDetails
-
getRowData
Parses source data and returns string array with values in same positions as target columns.- Parameters:
data
- CsvData from the sourcedataType
- CsvData type constant. Example: CsvData.ROW_DATA, CsvData.OLD_DATA- Returns:
- Values for target columns (as strings)
-
getTargetColumnReferencesMap
Looks up column mappings in the cache (or generates them). Used to quickly copy data from source columns into target columns. -
buildTargetColumnReferencesMap
Builds new column mappings and saves it to the cache. -
refreshTargetColumnReferencesMap
protected void refreshTargetColumnReferencesMap()Verifies that column mapping cache is up-to date. Rebuilds column mappings, if mismatch is detected. -
clearTargetColumnReferencesMap
protected void clearTargetColumnReferencesMap()Clears column mapping cache. Used when DDL changes impact column definitions. -
bindVariables
-
script
-
getLookupDataMap
-
getPkDataFor
-
end
- Specified by:
end
in interfaceIDataWriter
-
end
- Specified by:
end
in interfaceIDataWriter
-
close
public void close()- Specified by:
close
in interfaceIDataResource
-
hasFilterThatHandlesMissingTable
-
allowInsertIntoAutoIncrementColumns
-
lookupTableAtTarget
-
getBatch
-
getContext
-
getConflictResolver
-
setConflictResolver
-
getTargetTable
-
getSourceTable
-
getStatistics
- Specified by:
getStatistics
in interfaceIDataResource
-
getWriterSettings
-