Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
2.7.3
-
None
-
spring-boot-2.5.2
Description
Sidenote: I don't know exactly is this is an issue of hibernate or mariadb-java-client.
But the issue occurs as soon as mariadb-java-client is upgraded from 2.7.2 to 2.7.3, thus there must have been a breaking change inside?
Precondition: create a mariadb or mysql table as follows:
CREATE TABLE example (
|
id bigint NOT NULL AUTO_INCREMENT,
|
foo tinyint DEFAULT NULL,
|
PRIMARY KEY (id)
|
);
|
With entity class:
@Entity
|
public class Example {
|
@Id
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
public long id;
|
 |
@Column(columnDefinition = "TINYINT")
|
public Integer foo;
|
}
|
Run the application attached. The application runs and terminates without errors.
Now the interesting part: upgrade the mariadb version in `pom.xml` to:
<mariadb.version>2.7.3</mariadb.version>
|
(which is the natively shipped version in `spring-boot-2.5.2`).
Result: the startup validation fails:
2021-07-20 13:54:19.107 ERROR 66260 --- [ main] j.LocalContainerEntityManagerFactoryBean : Failed to initialize JPA EntityManagerFactory: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: wrong column type encountered in column [foo] in table [example]; found [bit (Types#TINYINT)], but expecting [tinyint (Types#INTEGER)]
|
2021-07-20 13:54:19.108 WARN 66260 --- [ main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: wrong column type encountered in column [foo] in table [example]; found [bit (Types#TINYINT)], but expecting [tinyint (Types#INTEGER)]
|
This means `mariadb-2.7.3` must have introduced a change that causes this error. But I could not find any hint on this inside the changelogs. Please have a look.