Fixed message with table name in dbunit

The dbunit data is filled with lowercase names according to the schema definition. Why every time you get a warning with a corrected table, I run 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 
+4
source share
1 answer

In fact, DBUnit mentions this.

Here is the javadoc of the DatabaseConnection constructor

... schema is the database schema. Please note that the schema name is case sensitive. This is necessary because schemas with the same name, but a different case may coexist in the same database. ...

I think DBUnit developers are correcting the example schema name to avoid the problem that this behavior might cause.

DatabaseConnection is a universal superclass for all other databases specified by DatabaseConnection , H2DatabaseConnection , for example.

When a DatabaseConnection is created, DBUnit will retrieve metadata about the database, which is an implementation of java.sql.DatabaseMetaData way, from the jdbc connection.

After that, DBUnit will correct the schema name by checking the metadata, which is the reason you always get log messages.

DBUnit use the following DatabaseMetaData methods to validate

 boolean storesUpperCaseIdentifiers() throws SQLException; boolean storesLowerCaseIdentifiers() throws SQLException; 

and here is the jdbc H2 driver implementation

 public boolean storesUpperCaseIdentifiers() { debugCodeCall("storesUpperCaseIdentifiers"); return true; } 

therefore, the user table becomes USER

0
source

Source: https://habr.com/ru/post/1301785/


All Articles