Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting hibernate.query.mutation_strategy.global_temporary.create_tables to false has no effect #2055

Open
fdittz opened this issue Dec 23, 2024 · 0 comments
Milestone

Comments

@fdittz
Copy link

fdittz commented Dec 23, 2024

Hello,

We are using Micronaut 4.7.2, Hibernate Reactive 2.4.2.Final, and Oracle as our database. Since we are working with legacy data, our model entities utilize inheritance, specifically InheritanceType.JOINED.

I noticed that when we start our application, it attempts to create global temporary tables regardless of the hibernate.query.mutation_strategy.global_temporary.create_tables setting. This issue does not occur if we disable Hibernate Reactive by setting jpa.default.reactive to false.

While debugging the startup process, I came across the org.hibernate.reactive.query.sqm.mutation.internal.temptable.ReactiveGlobalTemporaryTableStrategy class. In its prepare method, the following code caught my attention:

default void prepare(MappingModelCreationProcess mappingModelCreationProcess, JdbcConnectionAccess connectionAccess, CompletableFuture<Void> tableCreatedStage) {
    if (isPrepared()) {
        return;
    }

    setPrepared(true);

    final ConfigurationService configService = mappingModelCreationProcess
            .getCreationContext().getBootstrapContext()
            .getServiceRegistry().getService(ConfigurationService.class);
    boolean createIdTables = configService
            .getSetting(GlobalTemporaryTableStrategy.CREATE_ID_TABLES, StandardConverters.BOOLEAN, true);

    if (!createIdTables) {
        tableCreatedStage.complete(null);
    }

    LOG.debugf("Creating global-temp ID table: %s", getTemporaryTable().getTableExpression());

    connectionStage()
            .thenCompose(this::createTable)
            .whenComplete((connection, throwable) -> releaseConnection(connection)
                    .thenAccept(v -> {
                        if (throwable == null) {
                            setDropIdTables(configService);
                            tableCreatedStage.complete(null);
                        } else {
                            tableCreatedStage.completeExceptionally(throwable);
                        }
                    })
            );
}

I believe the issue lies in lines 65-67:

if (!createIdTables) {
    tableCreatedStage.complete(null);
}

Although the setting is read correctly, the method does not stop execution at this point. It proceeds to create the tables in the subsequent lines.

To address this, I overwrote this class in my project and added a return statement inside this conditional block. After making this change, the tables were no longer created. However, I am uncertain if this is the best approach and suspect this behavior might be a bug.

Thank you.

@DavideD DavideD added this to the next milestone Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants