We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Env:
Spring Boot - 3.2.1 Hibernet - 6.4.1 Mysql - 5.7 Liquibase : 4.25.1 Liquibase Hibernate6: 4.25.1
Gradle:
liquibase { activities { main { defaultsFile "liquibase.properties" changelogFile "base.mysql.sql" referenceUrl "hibernate:spring:com.xxx.model?dialect=org.hibernate.dialect.MySQLDialect" } } } dependencies { liquibaseRuntime 'com.mysql:mysql-connector-j' liquibaseRuntime 'org.liquibase:liquibase-core:4.25.1' liquibaseRuntime 'info.picocli:picocli:4.7.5' liquibaseRuntime 'org.yaml:snakeyaml:2.0' liquibaseRuntime 'org.liquibase.ext:liquibase-hibernate6:4.25.1' liquibaseRuntime 'org.springframework.boot:spring-boot-starter' liquibaseRuntime 'org.springframework.boot:spring-boot-starter-data-jpa' liquibaseRuntime sourceSets.main.output }
Entity class:
public enum Status { ACTIVE, INACTIVE } @Entity @Getter @Table(name = "user") public class User { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id", nullable = false) private Long id; @Enumerated(EnumType.STRING) @Column(nullable = false) private Status status; }
Try to use: gradle diffChangelog to generate sql file, got:
gradle diffChangelog
CREATE TABLE user (id BIGINT AUTO_INCREMENT NOT NULL, status ENUM NOT NULL, CONSTRAINT userPK PRIMARY KEY (id));
which result in wrong SQL.
expected:
CREATE TABLE user (id BIGINT AUTO_INCREMENT NOT NULL, status ENUM('ACTIVE', 'INACTIVE') NOT NULL, CONSTRAINT userPK PRIMARY KEY (id));
Root cause: According https://docs.jboss.org/hibernate/orm/6.2/migration-guide/migration-guide.html#ddl-implicit-datatype-enum, Hibernate 6 uses enum types on MySQL by default, but Liquibase hibernate6 class ColumnSnapshotGenerator#toDataType cannot process hibernateType with ENUM('ACTIVE', 'INACTIVE'), this method just keep ENUM as sql type.
enum
ColumnSnapshotGenerator#toDataType
hibernateType
ENUM('ACTIVE', 'INACTIVE')
ENUM
Workaround: Right now, we are add:
@JdbcTypeCode(SqlTypes.VARCHAR) private Status status;
to make sure still using old stype VARCHAR for ENUM.
VARCHAR
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Env:
Gradle:
Entity class:
Try to use:
gradle diffChangelog
to generate sql file, got:which result in wrong SQL.
expected:
Root cause:
According https://docs.jboss.org/hibernate/orm/6.2/migration-guide/migration-guide.html#ddl-implicit-datatype-enum, Hibernate 6 uses
enum
types on MySQL by default, but Liquibase hibernate6 classColumnSnapshotGenerator#toDataType
cannot processhibernateType
withENUM('ACTIVE', 'INACTIVE')
, this method just keepENUM
as sql type.Workaround:
Right now, we are add:
to make sure still using old stype
VARCHAR
for ENUM.The text was updated successfully, but these errors were encountered: