Class DataToDatabaseSink
java.lang.Object
edu.internet2.middleware.grouper.ext.org.apache.ddlutils.io.DataToDatabaseSink
- All Implemented Interfaces:
DataSink
Data sink that directly inserts the beans into the database. If configured, it will make
sure that the beans are inserted in the correct order according to the foreignkeys. Note
that this will only work if there are no circles.
- Version:
- $Revision: 289996 $
-
Constructor Summary
ConstructorDescriptionDataToDatabaseSink
(Platform platform, Database model) Creates a new sink instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addBean
(org.apache.commons.beanutils.DynaBean bean) Adds a dyna bean.void
end()
Notifies the sink that all beans have been added.int
Returns the (maximum) number of beans to insert in one batch.boolean
Determines whether the sink delays the insertion of beans so that the beans referenced by it via foreignkeys are already inserted into the database.boolean
Determines whether this sink halts when an error happens during the insertion of a bean into the database.boolean
Determines whether batch mode is used for inserting the beans.void
setBatchSize
(int batchSize) Sets the (maximum) number of beans to insert in one batch.void
setEnsureForeignKeyOrder
(boolean ensureFkOrder) Specifies whether the sink shall delay the insertion of beans so that the beans referenced by it via foreignkeys are already inserted into the database.
Note that you should careful with settinghaltOnErrors
to false as this might result in beans not inserted at all.void
setHaltOnErrors
(boolean haltOnErrors) Specifies whether this sink halts when an error happens during the insertion of a bean into the database.void
setUseBatchMode
(boolean useBatchMode) Specifies whether batch mode is used for inserting the beans.void
start()
Notifies the sink that beans will be added.
-
Constructor Details
-
DataToDatabaseSink
Creates a new sink instance.- Parameters:
platform
- The database platformmodel
- The database model
-
-
Method Details
-
isHaltOnErrors
public boolean isHaltOnErrors()Determines whether this sink halts when an error happens during the insertion of a bean into the database. Default istrue
.- Returns:
true
if the sink stops when an error occurred
-
setHaltOnErrors
public void setHaltOnErrors(boolean haltOnErrors) Specifies whether this sink halts when an error happens during the insertion of a bean into the database.- Parameters:
haltOnErrors
-true
if the sink shall stop when an error occurred
-
isEnsureFkOrder
public boolean isEnsureFkOrder()Determines whether the sink delays the insertion of beans so that the beans referenced by it via foreignkeys are already inserted into the database.- Returns:
true
if beans are inserted after its foreignkey-references
-
setEnsureForeignKeyOrder
public void setEnsureForeignKeyOrder(boolean ensureFkOrder) Specifies whether the sink shall delay the insertion of beans so that the beans referenced by it via foreignkeys are already inserted into the database.
Note that you should careful with settinghaltOnErrors
to false as this might result in beans not inserted at all. The sink will then throw an appropriate exception at the end of the insertion process (methodend()
).- Parameters:
ensureFkOrder
-true
if beans shall be inserted after its foreignkey-references
-
isUseBatchMode
public boolean isUseBatchMode()Determines whether batch mode is used for inserting the beans.- Returns:
true
if batch mode is used (false
per default)
-
setUseBatchMode
public void setUseBatchMode(boolean useBatchMode) Specifies whether batch mode is used for inserting the beans. Note that this requires that the primary key values are not defined by the database.- Parameters:
useBatchMode
-true
if batch mode shall be used
-
getBatchSize
public int getBatchSize()Returns the (maximum) number of beans to insert in one batch.- Returns:
- The number of beans
-
setBatchSize
public void setBatchSize(int batchSize) Sets the (maximum) number of beans to insert in one batch.- Parameters:
batchSize
- The number of beans
-
end
Notifies the sink that all beans have been added.- Specified by:
end
in interfaceDataSink
- Throws:
DataSinkException
-
start
Notifies the sink that beans will be added.- Specified by:
start
in interfaceDataSink
- Throws:
DataSinkException
-
addBean
Adds a dyna bean.- Specified by:
addBean
in interfaceDataSink
- Parameters:
bean
- The dyna bean to add- Throws:
DataSinkException
-