现在的位置: 首页 > 综合 > 正文

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

2013年09月28日 ⁄ 综合 ⁄ 共 896字 ⁄ 字号 评论关闭
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的绑定.

抱歉!评论已关闭.