Skip to content

Fix import.sql not executed when using only StatelessSession (no entities)#53419

Closed
lucamolteni wants to merge 1 commit intoquarkusio:mainfrom
lucamolteni:QUARKUS-53413
Closed

Fix import.sql not executed when using only StatelessSession (no entities)#53419
lucamolteni wants to merge 1 commit intoquarkusio:mainfrom
lucamolteni:QUARKUS-53413

Conversation

@lucamolteni
Copy link
Copy Markdown
Contributor

@lucamolteni lucamolteni commented Apr 2, 2026

Summary

  • When there are no @Entity classes but StatelessSession is used with import.sql, the SQL script was not executed

  • Root cause: metadata.getContributors() returns an empty set with no entities, causing SchemaManagementToolCoordinator to skip all schema actions including import.sql execution

  • Fix: ensure PrevalidatedQuarkusMetadata.getContributors() always returns at least one contributor so configured schema actions are processed

  • Fixes: import.sql not executed when not defining entities #53413

Test plan

  • Added ImportSqlLoadScriptNoEntitiesTestCase that verifies import.sql runs without any @Entity
  • All existing sql_load_script tests pass
  • All existing NoEntities tests pass
  • Full Quarkus build passes

🤖 Generated with Claude Code

…ties)

When there are no @entity classes, metadata.getContributors() returns an
empty set, causing SchemaManagementToolCoordinator to skip all schema
actions including import.sql execution. Ensure at least one contributor
exists so configured schema actions are always processed.

Fixes: quarkusio#53413

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@quarkus-bot
Copy link
Copy Markdown

quarkus-bot bot commented Apr 2, 2026

/cc @gsmet (hibernate-orm)

@lucamolteni lucamolteni requested a review from mbellade April 2, 2026 12:53
@quarkus-bot
Copy link
Copy Markdown

quarkus-bot bot commented Apr 2, 2026

Status for workflow Quarkus CI

This is the status report for running Quarkus CI on commit 3df0315.

Failing Jobs

Status Name Step Failures Logs Raw logs Build scan
✔️ JVM Integration Tests - JDK 17 Logs Raw logs 🔍
✔️ JVM Integration Tests - JDK 17 Windows Logs Raw logs 🔍
✔️ JVM Integration Tests - JDK 21 Logs Raw logs 🔍
✔️ JVM Integration Tests - JDK 25 Logs Raw logs 🔍
JVM Integration Tests - JDK 25 Semeru Build Failures Logs Raw logs 🔍

You can consult the Develocity build scans.

Failures

⚙️ JVM Integration Tests - JDK 25 Semeru #

- Failing: integration-tests/kubernetes-service-binding-jdbc 

📦 integration-tests/kubernetes-service-binding-jdbc

Failed to execute goal io.fabric8:docker-maven-plugin:0.48.1:stop (docker-start) on project quarkus-integration-test-kubernetes-service-binding-jdbc: At least one exception thrown during container removal.


Flaky tests - Develocity

⚙️ JVM Tests - JDK 17

📦 extensions/smallrye-reactive-messaging-kafka/deployment

io.quarkus.smallrye.reactivemessaging.kafka.deployment.testing.KafkaDevServicesContinuousTestingTestCase.testContinuousTestingScenario2 - History

  • org.testcontainers.containers.ContainerLaunchException: Container startup failed for image docker.io/library/redis:7 - java.util.concurrent.CompletionException
Details
java.util.concurrent.CompletionException: org.testcontainers.containers.ContainerLaunchException: Container startup failed for image docker.io/library/redis:7
	at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315)
	at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1807)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)

@lucamolteni
Copy link
Copy Markdown
Contributor Author

"org.testcontainers.containers.ContainerLaunchException: Container startup failed for image docker.io/library/redis:7 - java.util.concurrent.CompletionException"

Failure seems unrelated

@lucamolteni lucamolteni requested a review from gsmet April 3, 2026 07:41
// Even with no entities, we need at least one contributor so that
// SchemaManagementToolCoordinator processes the configured schema actions
// (e.g. executing import.sql). See https://github.com/quarkusio/quarkus/issues/53413
return Set.of("no-entities");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks odd to pass a dummy value. Given @mbellade gave his approval, I suppose it's the vetted way in Hibernate ORM to achieve that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks odd to pass a dummy value. Given @mbellade gave his approval, I suppose it's the vetted way in Hibernate ORM to achieve that?

good question I didn't know either, initially Claud put orm stating that was the usual case for contributors, but I checked the any string would work so I put something that would state that we're in a specific case

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gsmet @lucamolteni I'm guessing this is necessary to circumvent the logic of this method in Hibernate ORM, which always expects at least one contributor to exist, since outside of Quarkus there will always be at least one entity mapping (and each entity mapping has its contributor).

If we wanted to avoid this "hack-ish" way of triggering ORM's built-in schema management coordinator, we would need to either modify it at the ORM-level, or introduce some custom logic when bootstrapping Hibernate in Quarkus (e.g. in FastBootEntityManagerFactoryBuilder) that manually invokes some schema manager methods for the special "no-entities" case.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah IMO this is basically working around a bug, or at least a gap, in Hibernate ORM.

@lucamolteni please file an issue in ORM and either fix it there, or at least reference the issue in a comment here?

@gsmet
Copy link
Copy Markdown
Member

gsmet commented Apr 7, 2026

since outside of Quarkus there will always be at least one entity mapping (and each entity mapping has its contributor

So that's where I'm not sure I follow. Wouldn't this case of using only the StatelessSession and wanting the import.sql to be executed be a valid Hibernate ORM use case?

@mbellade
Copy link
Copy Markdown
Member

mbellade commented Apr 7, 2026

Wouldn't this case of using only the StatelessSession and wanting the import.sql to be executed be a valid Hibernate ORM use case?

@gsmet sure it would, we just probably never explicitly tested the functionality; AFAIK we only ever targeted this "entity-less mode" in Quarkus, but as I said:

[...] we would need to either modify it at the ORM-level

It's a valid approach, we just need an upstream issue and someone working on it :)

Copy link
Copy Markdown
Member

@yrodiere yrodiere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will most likely result in breaking changes for some users who have an import.sql in their classpath by mistake -- yes it's preposterous, but we've had reports in the past.

This is also a very reasonable breaking change IMO, so we can proceed, but please write up a migration guide entry?

// Even with no entities, we need at least one contributor so that
// SchemaManagementToolCoordinator processes the configured schema actions
// (e.g. executing import.sql). See https://github.com/quarkusio/quarkus/issues/53413
return Set.of("no-entities");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah IMO this is basically working around a bug, or at least a gap, in Hibernate ORM.

@lucamolteni please file an issue in ORM and either fix it there, or at least reference the issue in a comment here?

@lucamolteni
Copy link
Copy Markdown
Contributor Author

lucamolteni commented Apr 7, 2026

This will most likely result in breaking changes for some users who have an import.sql in their classpath by mistake -- yes it's preposterous, but we've had reports in the past.

This is also a very reasonable breaking change IMO, so we can proceed, but please write up a migration guide entry?

I've created

https://hibernate.atlassian.net/browse/HHH-20321

and assigned it to me

@lucamolteni
Copy link
Copy Markdown
Contributor Author

This will most likely result in breaking changes for some users who have an import.sql in their classpath by mistake -- yes it's preposterous, but we've had reports in the past.
This is also a very reasonable breaking change IMO, so we can proceed, but please write up a migration guide entry?

I've created

https://hibernate.atlassian.net/browse/HHH-20321

and assigned it to me

PR for 7.3 hibernate/hibernate-orm#12138
forward port to main hibernate/hibernate-orm#12139

@yrodiere
Copy link
Copy Markdown
Member

This will most likely result in breaking changes for some users who have an import.sql in their classpath by mistake -- yes it's preposterous, but we've had reports in the past.
This is also a very reasonable breaking change IMO, so we can proceed, but please write up a migration guide entry?

I've created
https://hibernate.atlassian.net/browse/HHH-20321
and assigned it to me

PR for 7.3 hibernate/hibernate-orm#12138 forward port to main hibernate/hibernate-orm#12139

Thanks. So I imagine we will close this PR (#53419) and wait for this fix to make its way into Quarkus?

@yrodiere yrodiere added the triage/on-ice Frozen until external concerns are resolved label Apr 10, 2026
@quarkus-bot quarkus-bot bot added the triage/invalid This doesn't seem right label Apr 10, 2026
@lucamolteni
Copy link
Copy Markdown
Contributor Author

PR for 7.3 hibernate/hibernate-orm#12138 forward port to main hibernate/hibernate-orm#12139

Thanks. So I imagine we will close this PR (#53419) and wait for this fix to make its way into Quarkus?

^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/hibernate-orm Hibernate ORM triage/flaky-test triage/invalid This doesn't seem right triage/on-ice Frozen until external concerns are resolved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

import.sql not executed when not defining entities

4 participants