HHH-18026 Add test for issue

This commit is contained in:
Marco Belladelli 2024-05-16 10:46:40 +02:00
parent 7a315b0d8d
commit 0515b71a81
1 changed files with 22 additions and 0 deletions

View File

@ -15,6 +15,7 @@ import org.hibernate.annotations.RowId;
import org.hibernate.annotations.SourceType;
import org.hibernate.annotations.UpdateTimestamp;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.engine.jdbc.spi.SqlExceptionHelper;
import org.hibernate.engine.spi.EntityEntry;
import org.hibernate.engine.spi.PersistenceContext;
import org.hibernate.generator.EventType;
@ -22,10 +23,12 @@ import org.hibernate.generator.values.GeneratedValuesMutationDelegate;
import org.hibernate.id.insert.AbstractReturningDelegate;
import org.hibernate.id.insert.AbstractSelectingDelegate;
import org.hibernate.id.insert.UniqueKeySelectingDelegate;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.sql.model.MutationType;
import org.hibernate.testing.jdbc.SQLStatementInspector;
import org.hibernate.testing.logger.Triggerable;
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
@ -33,7 +36,12 @@ import org.hibernate.testing.orm.junit.ServiceRegistry;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.hibernate.testing.orm.junit.Setting;
import org.hibernate.testing.orm.logger.LoggerInspectionExtension;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.jboss.logging.Logger;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
@ -76,6 +84,7 @@ public class MutationDelegateIdentityTest {
assertThat( inspector.getSqlQueries().get( 0 ) ).contains( "insert" );
inspector.assertExecutedCount( delegate instanceof AbstractReturningDelegate ? 1 : 2 );
assertThat( triggerable.wasTriggered() ).isFalse();
} );
}
@ -240,6 +249,19 @@ public class MutationDelegateIdentityTest {
return entityDescriptor.getMutationDelegate( mutationType );
}
private Triggerable triggerable;
@RegisterExtension
public LoggerInspectionExtension logger = LoggerInspectionExtension.builder().setLogger(
Logger.getMessageLogger( CoreMessageLogger.class, SqlExceptionHelper.class.getName() )
).build();
@BeforeAll
public void setUp(SessionFactoryScope scope) {
triggerable = logger.watchForLogMessages( "SQL Error:" );
triggerable.reset();
}
@Entity( name = "IdentityOnly" )
public static class IdentityOnly {
@Id