Default CLOB length in MySQL (Hibernate 6)

Hello,

I am migrating from hibernate 5 to hibernate 6.
I am having a schema validation issue for CLOB type in MySQL.
It seems like the default length for CLOB is set to 255 which cause below error:

Exception in thread "main" org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: wrong column type encountered in column [name] in table [Foo]; found [longtext (Types#LONGVARCHAR)], but expecting [tinytext (Types#CLOB)]
	at org.hibernate.tool.schema.internal.AbstractSchemaValidator.validateColumnType(AbstractSchemaValidator.java:179)
	at org.hibernate.tool.schema.internal.AbstractSchemaValidator.validateTable(AbstractSchemaValidator.java:151)
	at org.hibernate.tool.schema.internal.GroupedSchemaValidatorImpl.validateTables(GroupedSchemaValidatorImpl.java:46)
	at org.hibernate.tool.schema.internal.AbstractSchemaValidator.performValidation(AbstractSchemaValidator.java:96)
	at org.hibernate.tool.schema.internal.AbstractSchemaValidator.doValidation(AbstractSchemaValidator.java:74)
	at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:65)
	at org.example.Main.validateSchema(Main.java:37)
	at org.example.Main.main(Main.java:13)

I reproduced the issue in the example below:

CREATE TABLE foodb.Foo (id INT, name LONGTEXT);

pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>hibernate5</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <!--<dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.6.14.Final</version>
        </dependency>-->

        <dependency>
            <groupId>org.hibernate.orm</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>6.1.6.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate.orm</groupId>
            <artifactId>hibernate-ant</artifactId>
            <version>6.1.6.Final</version>
        </dependency>
        
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.32</version>
        </dependency>
    </dependencies>

    <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

</project>

Foo.java

package org.example;

/*import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;*/

import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;

@Entity
@Table(name = "Foo")
public class Foo {

    @Id
    private int id;

    @Lob
    private String name;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}

Main.java

package org.example;

import org.hibernate.boot.Metadata;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.tool.hbm2ddl.SchemaValidator;

import java.util.Map;

public class Main {
    public static void main(String[] args) {
        StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder()
                .applySettings(
                        Map.of(
                                "hibernate.connection.driver_class", "com.mysql.jdbc.Driver",
                                "hibernate.dialect", "org.hibernate.dialect.MySQL8Dialect",
                                "hibernate.connection.url", "jdbc:mysql://localhost/foodb",
                                "hibernate.connection.username", "admin",
                                "hibernate.connection.password", "admin",
                                "hibernate.default_schema", "foodb"
                        )
                )
                .build();

        Metadata metadata = new MetadataSources(serviceRegistry)
                .addAnnotatedClass(Foo.class)
                .buildMetadata();

        new SchemaValidator().validate(metadata, serviceRegistry);
    }
}

Thanks for the report. Please create a JIRA issue for this bug. In the meantime, you should be able to workaround this by specifying a length via @Column(length = 16_777_216) since 16_777_215 is the maximum mediumtext length.