Dbunit中DatabaseOperation.DELETE和DatabaseOperation.DELETE_ALL的差别

来源:互联网 发布:评价红模仿 知乎 编辑:程序博客网 时间:2024/05/16 23:55
DatabaseOperation.DELETE
This operation deletes only the dataset contents from the database. This operation does not delete the entire table contents but only data that are present in the dataset.

DatabaseOperation.DELETE_ALL  Deletes all rows of tables present in the specified dataset. If the dataset does not contains a particular table, but that table exists in the database, the database table is not affected. Table are truncated in reverse sequence.

DatabaseOperation.CLEAN_INSERT  This composite operation performs a DELETE_ALL operation followed by an INSERT operation. This is the safest approach to ensure that the database is in a known state. This is appropriate for tests that require the database to only contain a specific set of data.

以上信息来自http://dbunit.sourceforge.net/components.html

从上开始看出,
DatabaseOperation.DELETE 只删除数据集文件中准备的数据.不删除你另外插入的数据
DatabaseOperation.DELETE_ALL 将删除数据集文件中出现的表中的所有数据,也就是如果你往数据集表中插入了数据,那么也会删除.表本身不会被删除.而且表会被trucate

另外:DatabaseOperation.CLEAN_INSERT是DELETE_ALL和 INSERT的绑定.
原创粉丝点击