Skip to content

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

@fdittz

Description

@fdittz

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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions