HHH-17829 - [MySQL] Schema-validation: wrong column type encountered in column [activated] in table [jhi_user]; found [tinyint (Types#TINYINT)], but expecting [bit (Types#BOOLEAN)]

Test that using `hibernate.type.preferred_boolean_jdbc_type` allows successful validation
This commit is contained in:
Steve Ebersole 2024-06-11 06:41:59 -05:00
parent 45ea24d102
commit d1c80e1462
1 changed files with 28 additions and 0 deletions

View File

@ -9,6 +9,7 @@ package org.hibernate.orm.test.schemavalidation;
import java.util.EnumSet;
import java.util.Map;
import org.hibernate.SessionFactory;
import org.hibernate.boot.spi.MetadataImplementor;
import org.hibernate.cfg.MappingSettings;
import org.hibernate.engine.config.spi.ConfigurationService;
@ -69,6 +70,24 @@ public class BooleanAsTinyintValidationTests {
.doValidation( domainModelScope.getDomainModel(), executionOptions, ContributableMatcher.ALL );
}
@Test
void testRuntimeUsage(DomainModelScope domainModelScope) {
try (SessionFactory sessionFactory = domainModelScope.getDomainModel().buildSessionFactory()) {
sessionFactory.inTransaction( (session) -> {
session.persist( new Client( 1, "stuff", true ) );
} );
sessionFactory.inTransaction( (session) -> {
session.find( Client.class, 1 );
} );
sessionFactory.inTransaction( (session) -> {
session.createQuery( "from Client", Client.class ).list();
} );
sessionFactory.inTransaction( (session) -> {
session.createNativeQuery( "select * from Client", Client.class ).list();
} );
}
}
@BeforeEach
public void setUp(ServiceRegistryScope registryScope, DomainModelScope domainModelScope) {
final MetadataImplementor domainModel = domainModelScope.getDomainModel();
@ -148,6 +167,15 @@ public class BooleanAsTinyintValidationTests {
private Integer id;
private String name;
private boolean active;
public Client() {
}
public Client(Integer id, String name, boolean active) {
this.id = id;
this.name = name;
this.active = active;
}
}
}