andr1337228
andr1337228

Reputation: 23

H2 throws org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "USER" not found

I was trying to create some tests using @DataJpaTest, but I stumbled upon this error:

Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "USER" not found; SQL statement:
INSERT INTO `user` (`id`, `show_user_weight`, `username`, `password`) VALUES (1, 0, "admin", "adminpassword")

So I have an entity called "User", I think it's important to note that I don't use @Table annotation over it.

I have this data.sql script:

INSERT INTO `user`
(`id`,
`show_user_weight`,
`username`,
`password`)
VALUES
(1,
0,
"admin",
"adminpassword");

And I also have these lines in my application.properties:

spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect
spring.jpa.defer-datasource-initialization=true

I also tried the following, thinking that some problems arose due to table names ():

@DataJpaTest(properties = {
 "spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;ON_KEYWORDS=USER;DATABASE_TO_LOWER=TRUE"
}

When i run the the whole application using MySQL as a DataSourse, everything works fine.

I'd be very thankful for any help!

Upvotes: 0

Views: 36

Answers (0)

Related Questions