Skip to content

MrMiyagiSan/hibernate-schema-validation-failure

Repository files navigation

hibernate-schema-validation-failure Project

This project reproduces the issue described in quarkusio/quarkus#24742

Before running the project, please start the spanner emulators using:

docker-compose up

Two spanner emulators are started, one per datasource declared in application.properties.

Both emulator databases are initialized with the right schemas for each datasource / persistence unit. This can be verified by opening a shell to the running images and executing the following commands.

In the spanner emulator image for the default datasource:

gcloud spanner databases execute-sql car-rent --project=test-project --instance=test-instance --sql="SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='RentedCar'"

In the spanner emulator image for the read-database datasource:

gcloud spanner databases execute-sql car --project=test-project --instance=test-instance --sql="SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='Car'"

Regardless of both databases containing the tables as expected, the Schema-validation fails at application start up with:

2022-04-08 14:22:29,067 ERROR [io.qua.hib.orm.run.sch.SchemaManagementIntegrator] (Hibernate post-boot validation thread for <default>) Failed to validate Schema: Schema-validation: missing table [RentedCar]
2022-04-08 14:22:29,119 ERROR [io.qua.hib.orm.run.sch.SchemaManagementIntegrator] (Hibernate post-boot validation thread for <default>) The following SQL may resolve the database issues, as generated by the Hibernate schema migration tool. WARNING: You must manually verify this SQL is correct, this is a best effort guess, do not copy/paste it without verifying that it does what you expect.

START BATCH DDL;
create table RentedCar (id STRING(255) not null,carId STRING(255),endDate DATE,startDate DATE) PRIMARY KEY (id);
RUN BATCH;

The issue is reproducible with both Quarkus versions 2.8.0.CR1 and 2.7.5.Final


This project uses Quarkus, the Supersonic Subatomic Java Framework.

If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ .

Running the application in dev mode

You can run your application in dev mode that enables live coding using:

./mvnw compile quarkus:dev

NOTE: Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/.

Packaging and running the application

The application can be packaged using:

./mvnw package

It produces the quarkus-run.jar file in the target/quarkus-app/ directory. Be aware that it’s not an über-jar as the dependencies are copied into the target/quarkus-app/lib/ directory.

The application is now runnable using java -jar target/quarkus-app/quarkus-run.jar.

If you want to build an über-jar, execute the following command:

./mvnw package -Dquarkus.package.type=uber-jar

The application, packaged as an über-jar, is now runnable using java -jar target/*-runner.jar.

Creating a native executable

You can create a native executable using:

./mvnw package -Pnative

Or, if you don't have GraalVM installed, you can run the native executable build in a container using:

./mvnw package -Pnative -Dquarkus.native.container-build=true

You can then execute your native executable with: ./target/hibernate-schema-validation-failure-1.0.0-SNAPSHOT-runner

If you want to learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling.

Related Guides

  • Hibernate ORM with Panache (guide): Simplify your persistence code for Hibernate ORM via the active record or the repository pattern

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published