0

I updated my Spring boot version and that caused the hibernate version to update as well. These are the versions:

Spring boot - 2.7.0
Hibernate-core - 5.6.9
Hibernate-envers - 5.3.20.Final

It was updated from Spring boot version 2.3.9.RELEASE and Hibernate-core version 5.4.28.

When I run the test suite, I see the error Table REVINFO not found:

Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "REVINFO" not found; SQL statement:
alter table insights.templateTable_aud add constraint FK9dw2kc3x0ti0c559slp64avtx foreign key (rev) references revinfo [42102-212]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:502) ~[h2-2.1.212.jar:2.1.212]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:477) ~[h2-2.1.212.jar:2.1.212]

I tried creating the revinfo table in my schema.sql but I still get the same error. Any idea what might be wrong?

covfefe
  • 2,485
  • 8
  • 47
  • 77
  • What are the versions you updated from? Maybe the table name is in caps while you defined is as lowercase? You can try to increase the log level to log the sql statements: `-Dhibernate.show_sql=true` Or set the table name with ` @Table(name= "revinfo")` – Willem Jul 13 '22 at 20:04
  • It was updated from Spring boot version `2.3.9.RELEASE` and Hibernate-core version `5.4.28`. The table revinfo is supposed to be generated automatically for Audited tables, so it's not something that I created. – covfefe Jul 13 '22 at 20:25
  • Not sure why upgrading Hibernate and Spring boot would cause the error. But you can set `spring.jpa.hibernate.ddl-auto` explicitly and the standard Hibernate property values are `none`, `validate`, `update`, `create`, and `create-drop`. Spring Boot chooses a default value for you based on whether it thinks your database is embedded. It defaults to `create-drop` if no schema manager has been detected or `none` in all other cases. An embedded database is detected by looking at the Connection type and JDBC url. hsqldb, h2, and derby are candidates, and others are not. – Haoliang Jul 14 '22 at 00:58
  • https://docs.spring.io/spring-boot/docs/2.7.x/reference/html/howto.html#howto.data-initialization.using-jpa – Haoliang Jul 14 '22 at 00:58
  • Hi, uses the H2 database logs to know to find out the real reason :https://stackoverflow.com/a/72712120/4017037 – stacky Jul 21 '22 at 14:21

1 Answers1

0

It looks like the revinfo table is automatically generated; it's not explicitly defined in the Spring project. The classes that have an @Audited tag above them have an audited table automatically generated for them.

Check whether you need that audit log table to be there and if there is no need try removing the @Audited annotation and try restarting your server.

SARATHI
  • 126
  • 1
  • 7