question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Column not found exception, with @ExpectedDatabase

See original GitHub issue

Hey. I’m very keen on your helpful framework, thanks!

But some days ago I get the issue with @ExpectedDatabase annotation and table, names users. When I was running my tests, unexpectedly I’ve found message, that column admin can’t be found for table users. That was weird, 'cause I have not had that column neither under my entity mappings nor under expected datasets. So I’ve started a little investigation, and found, that H2 has its own table, named users as well. Here is the link with H2 information schema description: http://www.h2database.com/html/grammar.html#information_schema But, when I was doing my checks w.o. using ExpectedDatabase annotations everything went fine. I had not had any similar exceptions. So, when I was in debug, I’ve found, that table’s metadata, that populated during test indeed contained admin column from H2 own users table, and merged my table structure. So I decided to wrote a little test project to illustrate this issue, you could simple try by cloning my repository: https://github.com/vict0r81/spring-dbunit-test

Hope my description will help you to bother that kind of problem.

Thanks, Victor.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
vict0r81commented, Sep 9, 2016

Hey!

Thanks, @sylvietseng for your solution. I’ve combined it with @FingolfinTEK latest comment and now exception I got before has gone.

So, the final solution here based on such points:

  1. Updated my SpringH2Config.java with 2 beans you have provided;
  2. Changed my AbstractTestBase.java in this way: from
@DbUnitConfiguration(databaseConnection = "dataSource")

to

@DbUnitConfiguration

And bingo!

Thanks, again for your help.

P.S. all updated code in my repo if anyone need it 😉 P.S.S. I believe issue can be closed.

1reaction
sylvietsengcommented, Sep 4, 2016

setSchema in uppercase https://github.com/vict0r81/spring-dbunit-test/blob/master/src/test/java/com/example/config/SpringH2Config.java

@Bean
    public DatabaseConfigBean dbUnitDatabaseConfig() {
        final DatabaseConfigBean bean = new DatabaseConfigBean();
        bean.setDatatypeFactory(new H2DataTypeFactory());
        bean.setEscapePattern("`");
        return bean;
    }

    @Bean
    public DatabaseDataSourceConnectionFactoryBean dbUnitDatabaseConnection(DataSource dataSource) {
        final DatabaseDataSourceConnectionFactoryBean bean = new DatabaseDataSourceConnectionFactoryBean(dataSource);
        bean.setDatabaseConfig(dbUnitDatabaseConfig());
        bean.setSchema("PUBLIC");
        return bean;
    }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Ignore columns in ExpectedDataSet (dbunit) - java
In spring using spring-test-dbunit, you can write: @ExpectedDatabase(value="yourdataset.xml", assertionMode=DatabaseAssertionMode.NON_STRICT).
Read more >
springtestdbunit
When I was running my tests, unexpectedly I've found message, that column admin can't be ... Why do not put the Dataset that...
Read more >
SQW - DWE Design Studio
operator : No columns are defined in the XML table. SQW00902E operator : Invalid path. The generated XML document must have a single...
Read more >
Using Null Values in DbUnit Datasets
This means that the correct todo entry was not found from the database ... DbUnit uses the first tag for a table to...
Read more >
Frequently Asked Questions
This error occurs when no schema is specified and that DbUnit detect that it is getting columns information from multiple tables having the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found