|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.ddlutils.io.DataToDatabaseSink
public class DataToDatabaseSink
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.
Constructor Summary | |
---|---|
DataToDatabaseSink(Platform platform,
Database model)
Creates a new sink instance. |
Method Summary | |
---|---|
void |
addBean(org.apache.commons.beanutils.DynaBean bean)
Adds a dyna bean. |
void |
end()
Notifies the sink that all beans have been added. |
int |
getBatchSize()
Returns the (maximum) number of beans to insert in one batch. |
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. |
boolean |
isHaltOnErrors()
Determines whether this sink halts when an error happens during the insertion of a bean into the database. |
boolean |
isUseBatchMode()
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 setting haltOnErrors 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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DataToDatabaseSink(Platform platform, Database model)
platform
- The database platformmodel
- The database modelMethod Detail |
---|
public boolean isHaltOnErrors()
true
.
true
if the sink stops when an error occurredpublic void setHaltOnErrors(boolean haltOnErrors)
haltOnErrors
- true
if the sink shall stop when an error occurredpublic boolean isEnsureFkOrder()
true
if beans are inserted after its foreignkey-referencespublic void setEnsureForeignKeyOrder(boolean ensureFkOrder)
haltOnErrors
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 (method end()
).
ensureFkOrder
- true
if beans shall be inserted after its foreignkey-referencespublic boolean isUseBatchMode()
true
if batch mode is used (false
per default)public void setUseBatchMode(boolean useBatchMode)
useBatchMode
- true
if batch mode shall be usedpublic int getBatchSize()
public void setBatchSize(int batchSize)
batchSize
- The number of beanspublic void end() throws DataSinkException
end
in interface DataSink
DataSinkException
public void start() throws DataSinkException
start
in interface DataSink
DataSinkException
public void addBean(org.apache.commons.beanutils.DynaBean bean) throws DataSinkException
addBean
in interface DataSink
bean
- The dyna bean to add
DataSinkException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |