Skip to content

Commit d1c80e1

Browse files
committed
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
1 parent 45ea24d commit d1c80e1

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

hibernate-core/src/test/java/org/hibernate/orm/test/schemavalidation/BooleanAsTinyintValidationTests.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.util.EnumSet;
1010
import java.util.Map;
1111

12+
import org.hibernate.SessionFactory;
1213
import org.hibernate.boot.spi.MetadataImplementor;
1314
import org.hibernate.cfg.MappingSettings;
1415
import org.hibernate.engine.config.spi.ConfigurationService;
@@ -69,6 +70,24 @@ public ExceptionHandler getExceptionHandler() {
6970
.doValidation( domainModelScope.getDomainModel(), executionOptions, ContributableMatcher.ALL );
7071
}
7172

73+
@Test
74+
void testRuntimeUsage(DomainModelScope domainModelScope) {
75+
try (SessionFactory sessionFactory = domainModelScope.getDomainModel().buildSessionFactory()) {
76+
sessionFactory.inTransaction( (session) -> {
77+
session.persist( new Client( 1, "stuff", true ) );
78+
} );
79+
sessionFactory.inTransaction( (session) -> {
80+
session.find( Client.class, 1 );
81+
} );
82+
sessionFactory.inTransaction( (session) -> {
83+
session.createQuery( "from Client", Client.class ).list();
84+
} );
85+
sessionFactory.inTransaction( (session) -> {
86+
session.createNativeQuery( "select * from Client", Client.class ).list();
87+
} );
88+
}
89+
}
90+
7291
@BeforeEach
7392
public void setUp(ServiceRegistryScope registryScope, DomainModelScope domainModelScope) {
7493
final MetadataImplementor domainModel = domainModelScope.getDomainModel();
@@ -148,6 +167,15 @@ public static class Client {
148167
private Integer id;
149168
private String name;
150169
private boolean active;
170+
171+
public Client() {
172+
}
173+
174+
public Client(Integer id, String name, boolean active) {
175+
this.id = id;
176+
this.name = name;
177+
this.active = active;
178+
}
151179
}
152180

153181
}

0 commit comments

Comments
 (0)