Skip to content

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

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

Closed
fdittz opened this issue Dec 23, 2024 · 0 comments · Fixed by #2109 or #2112
Closed
Assignees
Labels
bug Something isn't working
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
@dreab8 dreab8 self-assigned this Feb 5, 2025
dreab8 added a commit to dreab8/hibernate-reactive that referenced this issue Feb 6, 2025
dreab8 added a commit to dreab8/hibernate-reactive that referenced this issue Feb 6, 2025
…gy.global_temporary.create_tables to false has no effect
dreab8 added a commit to dreab8/hibernate-reactive that referenced this issue Feb 12, 2025
dreab8 added a commit to dreab8/hibernate-reactive that referenced this issue Feb 12, 2025
dreab8 added a commit to dreab8/hibernate-reactive that referenced this issue Feb 12, 2025
…ionFactory.close()

PersistentTemporaryTable dropping is obtained setting PersistentTableStrategy.DROP_ID_TABLES to true
dreab8 added a commit to dreab8/hibernate-reactive that referenced this issue Feb 12, 2025
…gy.global_temporary.create_tables to false has no effect
dreab8 added a commit to dreab8/hibernate-reactive that referenced this issue Feb 12, 2025
…gy.global_temporary.create_tables to false has no effect
dreab8 added a commit to dreab8/hibernate-reactive that referenced this issue Feb 12, 2025
dreab8 added a commit to dreab8/hibernate-reactive that referenced this issue Feb 12, 2025
dreab8 added a commit to dreab8/hibernate-reactive that referenced this issue Feb 12, 2025
…ionFactory.close()

PersistentTemporaryTable dropping is obtained setting PersistentTableStrategy.DROP_ID_TABLES to true
dreab8 added a commit to dreab8/hibernate-reactive that referenced this issue Feb 12, 2025
…gy.global_temporary.create_tables to false has no effect
dreab8 added a commit to dreab8/hibernate-reactive that referenced this issue Feb 12, 2025
…gy.global_temporary.create_tables to false has no effect
dreab8 added a commit to dreab8/hibernate-reactive that referenced this issue Feb 12, 2025
…gy.global_temporary.create_tables to false has no effect
DavideD pushed a commit to DavideD/hibernate-reactive that referenced this issue Feb 13, 2025
DavideD pushed a commit to DavideD/hibernate-reactive that referenced this issue Feb 13, 2025
DavideD pushed a commit to DavideD/hibernate-reactive that referenced this issue Feb 13, 2025
…ionFactory.close()

PersistentTemporaryTable dropping is obtained setting PersistentTableStrategy.DROP_ID_TABLES to true
DavideD pushed a commit to DavideD/hibernate-reactive that referenced this issue Feb 13, 2025
The test is for temporary tables created for
storing ids
DavideD pushed a commit to DavideD/hibernate-reactive that referenced this issue Feb 13, 2025
The test is for temporary tables created for
storing ids
DavideD pushed a commit to DavideD/hibernate-reactive that referenced this issue Feb 13, 2025
The test is for temporary tables created for
storing ids
DavideD pushed a commit that referenced this issue Feb 13, 2025
DavideD pushed a commit that referenced this issue Feb 13, 2025
…y.close()

PersistentTemporaryTable dropping is obtained setting PersistentTableStrategy.DROP_ID_TABLES to true
DavideD pushed a commit that referenced this issue Feb 13, 2025
The test is for temporary tables created for
storing ids
DavideD pushed a commit to DavideD/hibernate-reactive that referenced this issue Feb 13, 2025
DavideD pushed a commit to DavideD/hibernate-reactive that referenced this issue Feb 13, 2025
DavideD pushed a commit to DavideD/hibernate-reactive that referenced this issue Feb 13, 2025
…ionFactory.close()

PersistentTemporaryTable dropping is obtained setting PersistentTableStrategy.DROP_ID_TABLES to true
DavideD pushed a commit to DavideD/hibernate-reactive that referenced this issue Feb 13, 2025
The test is for temporary tables created for
storing ids
DavideD pushed a commit to DavideD/hibernate-reactive that referenced this issue Feb 13, 2025
The test is for temporary tables created for
storing ids
DavideD added a commit to DavideD/hibernate-reactive that referenced this issue Feb 13, 2025
DavideD pushed a commit that referenced this issue Feb 13, 2025
DavideD pushed a commit that referenced this issue Feb 13, 2025
…y.close()

PersistentTemporaryTable dropping is obtained setting PersistentTableStrategy.DROP_ID_TABLES to true
DavideD pushed a commit that referenced this issue Feb 13, 2025
The test is for temporary tables created for
storing ids
@DavideD DavideD added the bug Something isn't working label Apr 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment