I have configured the application-local.yml like this to do some tests in local:
spring:
datasource:
url: jdbc:h2:file:./data/db-test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
username: dbtest
password: dbtest
driver-class-name: org.h2.Driver
jpa:
show-sql: true
generate-ddl: false
properties:
# to prevent this issue : https://stackoverflow.com/questions/4588755/disabling-contextual-lob-creation-as-createclob-method-threw-error
hibernate.temp.use_jdbc_metadata_defaults : false
hibernate:
dialect: org.hibernate.dialect.H2Dialect
hibernate:
ddl-auto: update
h2:
console:
enabled: true
path: /public/h2-console
liquibase:
enabled: false
The first time the server is started, I see some logs from Hibernate to create tables and the file for the database is created.
The issue is that when I restart the server, I have some errors because it tries to create again the same tables, constraints... I have the ddl-auto set to update so I do not understand why. I tried to update the generate-ddl
value to false but it is the same.
Here is an exemple of what I have:
Hibernate: create table myTable (id bigint not null, ..., primary key (id))
15:59:49.252 [restartedMain] WARN o.h.t.s.i.ExceptionHandlerLoggedImpl - GenerationTarget encountered exception accepting command : Error executing DDL "create table myTable (id bigint not null, ..., primary key (id))" via JDBC Statement
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "create table myTable(id bigint not null, ..., primary key (id))" via JDBC Statement
at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67)
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlString(AbstractSchemaMigrator.java:562)
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlStrings(AbstractSchemaMigrator.java:507)
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.createTable(AbstractSchemaMigrator.java:277)
at org.hibernate.tool.schema.internal.GroupedSchemaMigratorImpl.performTablesMigration(GroupedSchemaMigratorImpl.java:71)
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.performMigration(AbstractSchemaMigrator.java:207)
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.doMigration(AbstractSchemaMigrator.java:114)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:184)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:73)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:318)
What am I doing wrong please?