|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.ddlutils.task.DatabaseCommand
org.apache.ddlutils.task.ConvertingDatabaseCommand
org.apache.ddlutils.task.WriteDataToDatabaseCommand
Inserts the data defined by the data XML file(s) into the database. This requires the schema
in the database to match the schema defined by the XML files specified at the enclosing task.
DdlUtils will honor the order imposed by the foreign keys. Ie. first all required entries are
inserted, then the dependent ones. Obviously this requires that no circular references exist
in the schema (DdlUtils currently does not check this). Also, the referenced entries must be
present in the data, otherwise the task will fail. This behavior can be turned off via the
ensureForeignKeyOrder
attribute.
In order to define data for foreign key dependencies that use auto-incrementing primary keys,
simply use some unique values for their columns. DdlUtils then will automatically use the real
primary key values when inserting the data. Note though that not every database supports the
retrieval of auto-increment values which is necessary for this to work.
Field Summary |
Fields inherited from class org.apache.ddlutils.task.DatabaseCommand |
_log |
Constructor Summary | |
WriteDataToDatabaseCommand()
|
Method Summary | |
void |
addConfiguredFileset(org.apache.tools.ant.types.FileSet fileset)
Adds a fileset. |
void |
execute(DatabaseTaskBase task,
Database model)
Executes this command. |
void |
setBatchSize(int batchSize)
The maximum number of insert statements to combine in one batch. |
void |
setDataFile(File dataFile)
Specifies the name of the single XML file that contains the data to insert into the database. |
void |
setEnsureForeignKeyOrder(boolean ensureFKOrder)
Specifies whether the foreign key order shall be honored when inserting data into the database. |
void |
setUseBatchMode(boolean useBatchMode)
Specifies whether batch mode shall be used for inserting the data. |
void |
setUseExplicitIdentityValues(boolean useExplicitIdentityValues)
Defines whether values for identity columns in the data XML shall be used instead of letting the database define the value. |
Methods inherited from class org.apache.ddlutils.task.ConvertingDatabaseCommand |
addConfiguredConverter, getDataIO |
Methods inherited from class org.apache.ddlutils.task.DatabaseCommand |
getCatalogPattern, getDatabaseType, getDataSource, getPlatform, getSchemaPattern, isFailOnError, isRequiringModel, setFailOnError, setPlatformConfiguration |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public WriteDataToDatabaseCommand()
Method Detail |
public void setUseExplicitIdentityValues(boolean useExplicitIdentityValues)
ensureForeignKeyOrder
is
set to false, setting this to false
(the default) does not affect foreign
keys as DdlUtils will automatically update the values of the columns of foreign keys
pointing to the inserted row with the database-created values.
useExplicitIdentityValues
- true
if explicitly specified identity
column values should be inserted instead of letting
the database define the values for these columnspublic void addConfiguredFileset(org.apache.tools.ant.types.FileSet fileset)
fileset
- The additional input filespublic void setDataFile(File dataFile)
dataFile
- The data filepublic void setBatchSize(int batchSize)
useBatchMode
is true
.
batchSize
- The number of objectspublic void setUseBatchMode(boolean useBatchMode)
useBatchMode
- true
if batch mode shall be usedpublic void setEnsureForeignKeyOrder(boolean ensureFKOrder)
ensureFKOrder
- true
if the foreign key order shall be followedpublic void execute(DatabaseTaskBase task, Database model) throws org.apache.tools.ant.BuildException
task
- The executing taskmodel
- The database model
org.apache.tools.ant.BuildException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |