I'm trying to use TestContainers for my integration tests. I started using it instantiating objects like:
@ClassRule
public static PostgreSQLContainer postgres = (PostgreSQLContainer) new PostgreSQLContainer()
.withDatabaseName("producto")
.withInitScript("init.sql");
That way my entities classes work perfectly. But when I tried to use it via JDBC URL as described here, I get the following exception
rg.postgresql.util.PSQLException: ERROR: cross-database references are not implemented: "producto.producto.driver"
I'm using Spring Boot, so I'm defining the following properties in my application.properties to take advantage of Spring Boot autoconfiguration (and not defining the container in code anymore):
spring.datasource.driver-class-name=org.testcontainers.jdbc.ContainerDatabaseDrive
spring.datasource.url=jdbc:tc:postgresql://somehostname:someport/producto?TC_INITSCRIPT=init.sql
My entity class is defined as:
@Entity
@Table(name = "driver", schema = "producto", catalog = "producto")
public class DriverEntity { }
I don't really understand why it works when defining an object, but not when using the jdbc url don't.
¿Do I need to define other properties?