Skip to content
Advertisement

Why are postgresql tables empty although filled when starting Testcontainer?

I am using Testcontainers 1.15.2 (using postgres image 13.2-alpine) with Spring Boot 2.4.3. The Testcontainer is started using an init script which starts with a type definition, a table creation and insert values into it. I even perform a COMMIT; at the end but did not define a schema or so. When I start the Spring Boot app the console output shows me that the init script was executed successfully. When I execute a SELECT * FROM the result is empty. So…why are the postgresql tables empty although I did inserts before?

I instantiate the Testcontainer in an abstract superclass for tests to be used in all inheriting subclassing tests:

In a subclass I do:

…and the test is green but when I do

…the test is green but anschriftList is empty. Why?

And if I use Anschriften PK as a FK in Person entity…I get a LazyLoadingException although specifying fetch = FetchType.EAGER in the relationship definitions. Why?

Advertisement

Answer

In my application-test.yaml I defined

as I found this on the internet.

-> Outcommenting this line leads to filled tables.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement