更正了 dbunit 中的表名消息
dbunit 数据已根据架构定义使用小写表名填充。为什么每次我运行所有数据库(h2、mysql ..)的脚本时都会收到更正的表警告
[INFO] [dbunit:operation {execution: seed data}] 120 [main] INFO org.dbunit.database.DatabaseDataSet -
database name=H2
database version=1.2.128 (2010-01-30)
database major version=1
database minor version=2
jdbc driver name=H2 JDBC Driver
jdbc driver version=1.2.128 (2010-01-30)
jdbc driver major version=1
jdbc driver minor version=2
127 [main] INFO org.dbunit.util.SQLHelper - class org.dbunit.database.DatabaseTableMetaData. Corrected table name:
oldValue=user newValue=USER
dbunit data has been populated with lower case table names as per schema definition. Why do you get a corrected table warning every time, I run the scripts for all databases (h2, mysql ..)
[INFO] [dbunit:operation {execution: seed data}] 120 [main] INFO org.dbunit.database.DatabaseDataSet -
database name=H2
database version=1.2.128 (2010-01-30)
database major version=1
database minor version=2
jdbc driver name=H2 JDBC Driver
jdbc driver version=1.2.128 (2010-01-30)
jdbc driver major version=1
jdbc driver minor version=2
127 [main] INFO org.dbunit.util.SQLHelper - class org.dbunit.database.DatabaseTableMetaData. Corrected table name:
oldValue=user newValue=USER
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上DBUnit确实提到了这一点。
这是
DatabaseConnection
构造函数的javadoc我猜 DBUnit 开发人员更正了模式名称大小写,以避免这种行为可能导致的问题。
DatabaseConnection
是所有其他数据库指定的DatabaseConnection
的通用超类,例如H2DatabaseConnection
。当创建
DatabaseConnection
时,DBUnit将从jdbc连接检索有关数据库的元数据,顺便说一下,这是java.sql.DatabaseMetaData
的实现。之后,DBUnit 将通过检查元数据来更正模式名称,这就是您始终收到日志消息的原因。
DBUnit使用DatabaseMetaData的以下方法进行检查
,这里是H2 jdbc驱动程序的实现
,因此表“user”变成“USER”
Actually DBUnit does mention this.
Here is the javadoc of
DatabaseConnection
constructorI guess DBUnit developers correct the schema name case in order to avoid the problem that might cause by this behavior.
DatabaseConnection
is the universal super class of all other database specifiedDatabaseConnection
,H2DatabaseConnection
for example.When a
DatabaseConnection
is created, DBUnit will retrieve meta data about the database, which is an implementation ofjava.sql.DatabaseMetaData
by the way, from the jdbc connection.After that, DBUnit will correct the schema name by checking the metadata, that's the reason you always get the logging messages.
DBUnit use following methods of
DatabaseMetaData
to checkand here is the implementaion of H2 jdbc driver
so the table "user" becomes "USER"