Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-893

DatabaseMetaData.getColumns regression causing TINYINT(x) with x > 1 to return BIT type in place of TINYINT

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.7.3
    • Fix Version/s: 2.7.4
    • Component/s: metadata
    • Labels:
      None
    • Environment:
      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.

        Attachments

          Activity

            People

            Assignee:
            diego dupin Diego Dupin
            Reporter:
            membersound member sound
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Git Integration