0

so I have a model, lets assume it looks like this:

@TypeDefs(
  TypeDef(name = "string-array", typeClass = StringArrayType::class)
)
@Entity
@Validated
class User(
  @field:Id
  @field:GeneratedValue(strategy = GenerationType.IDENTITY)
  val id: Long = 0,

@Type(type = "string-array")
@Enumerated(EnumType.STRING)
val roles: Array<Role> = arrayOf(),



Thats there relevant part. There is a string array I want to use. The role is a enum (I did test it with raw string as well)

My configuratino is this:

server:
  port: 8090
spring:
  datasource:
    driver-class-name: org.testcontainers.jdbc.ContainerDatabaseDriver
    url: jdbc:tc:postgresql:14.5:///test
    username: test
    password: test
  jpa:
    hibernate:
      ddl-auto: create
    properties:
      hibernate:
        default_schema: test
  flyway:
    enabled: true

My test class is this:

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
@Testcontainers
@ActiveProfiles("test-containers")
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class AuthControllerTests {
  @Autowired
  lateinit var restTemplate: RestTemplate

  @field:Value("\${app.defaultAdminUserName}") <<-- this is immited from the upper config example but it is there
  lateinit var defaultAdminUsername: String

  @field:Value("\${app.defaultAdminPassword}")
  lateinit var defaultAdminPassword: String


@Test
fun loginTest() {
  val loginRequest = LoginRequest(
    username = defaultAdminUsername,
    password = defaultAdminPassword
  )

  val url = "http://localhost:8090/api/login"

  val loginResponse = restTemplate.postForEntity(url, loginRequest, JWTResponse::class.java)

  assertThat(loginResponse.statusCode).isEqualTo(HttpStatus.OK)
  assertThat(loginResponse.body).isNotNull
}

And when I try to run the test I get: org.hibernate.MappingException: No Dialect mapping for JDBC type: 2003

Is there away to use the postgresql types with test containers or should I stick with a presetup database ?

I tried different configurations and playing arraound with custom containers but I could not make it work

  • Does this answer your question? [No Dialect mapping for JDBC type: 2003](https://stackoverflow.com/questions/21630370/no-dialect-mapping-for-jdbc-type-2003) – user3738870 Nov 17 '22 at 10:34

0 Answers0