关于dbunit的导出数据排序问题
2011-05-08 18:47
579 查看
【问题描述】近日项目中用到 DBunit导出数据到一个XML文件里面,然后提交到版本控制器上面,这是为了实现工作在不同模块的同事之间实现单元测试数据共享,每次有同事更新数据文件之后,当比较和 前面版本有什么不同的时候,总是遇到由于导出数据没有被排序造成一些困扰,我们用的ant target是
【解决办法】导出的时候 在 export里面 用 query代替 table
注:参看 http://www.dbunit.org/anttask.html
<target name="export.testdata" description="exports test data from schema"> <property name="jdbc.url" value="jdbc:oracle:thin:@${common.db.host}:${common.db.port}:${common.db.sid}"/> <property name="out.file" location="../test/data/cust.xml"/> <echo message="exporting data from ${jdbc.url} (${common.db.user}) to ${out.file}"/> <dbunit driver="oracle.jdbc.driver.OracleDriver" url="${jdbc.url}" userid="${common.db.user}" password="${common.db.pwd}"> <dbconfig> <property name="datatypeFactory" value="org.dbunit.ext.oracle.OracleDataTypeFactory" /> <feature name="batchedStatements" value="true" /> </dbconfig> <export dest="${out.file}" format="flat"> <query name="IMPL" sql="select * from IMPL ORDER BY 1"/> <table name="USERS"/> </export> </dbunit> </target>
【解决办法】导出的时候 在 export里面 用 query代替 table
<target name="export.testdata" description="exports test data from schema"> <property name="jdbc.url" value="jdbc:oracle:thin:@${common.db.host}:${common.db.port}:${common.db.sid}"/> <property name="out.file" location="../test/data/cust.xml"/> <echo message="exporting data from ${jdbc.url} (${common.db.user}) to ${out.file}"/> <dbunit driver="oracle.jdbc.driver.OracleDriver" url="${jdbc.url}" userid="${common.db.user}" password="${common.db.pwd}"> <dbconfig> <property name="datatypeFactory" value="org.dbunit.ext.oracle.OracleDataTypeFactory" /> <feature name="batchedStatements" value="true" /> </dbconfig> <export dest="${out.file}" format="flat"> <query name="USERS" sql="select * from USERS ORDER BY 1"/> </export> </dbunit> </target>
注:参看 http://www.dbunit.org/anttask.html
相关文章推荐
- 每日学习心得:Linq解决DataTable按照某一列的值排序问题/DataTable 导出CSV文件/巧用text-overflow解决数据绑定列数据展示过长问题
- 关于insert into table 的数据排序问题
- 每日学习心得:Linq解决DataTable按照某一列的值排序问题/DataTable 导出CSV文件/巧用text-overflow解决数据绑定列数据展示过长问题
- 关于从GridView表中导出数据到Excel表中,身份证或者长度过长的数据在Excel中无法正常显示的问题
- 记录一笔关于PHPEXCEL导出大数据超时和内存溢出的问题
- 数据导出成Excel文件,关于字符集的问题
- 关于SXSSFWorkbook导出大批量数据的问题
- 关于利用heidiSQL或者sqlYog导入导出数据库和数据的问题(导出为excel再导入)
- 关于SQL SERVER导出数据的问题!
- 关于EXP-00056: 遇到 ORACLE 错误 1455 ORA-01455: 转换列溢出整数数据类型 EXP-00000: 导出终止失败 的问题解决方法整理
- 关于从GridView表中导出数据到Excel表中,身份证或者长度过长的数据在Excel中无法正常显示的问题
- 关于mysql中数据表的导入和导出问题。
- [疑]关于oracle导出数据时遇到的4031问题
- 关于导入导出数据中ID号变化的问题
- 关于Oracle 大数据排序问题的优化之一
- kettle对排序记录节点集群时,关于数据不准问题
- 关于H3 BPM数据库如何实现排序取数据的问题
- 关于ORCLE导出数据的问题
- 关于骨骼动画max数据导出到dx中一些问题总结
- 关于SXSSFWorkbook导出大批量数据的问题