V6.6.33,how disable Enum constraints

Automatically create tables, how disable Enum constraints, use int type mapping, and generate only fields.

for example:

@Column(name = "user_status")
private UserStatus userStatus;

generate SQL:

CREATE TABLE `user_info` (
  `id` bigint NOT NULL COMMENT 'id',
  `user_status` tinyint DEFAULT NULL,
  PRIMARY KEY (`id`),
  CONSTRAINT `user_info_chk_1` CHECK ((`user_status` between 0 and 2))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

What’s the problem? Why would you want to disable the generation of the check constraint?

Thank you for your reply. I’m sorry, but my English is not very good, so I’m using AI to translate.
Our system is currently undergoing a JDK upgrade, and Hibernate has been upgraded from version 3 to 6.6.33, which is a significant leap.
In the previously auto-generated table structures, there were no constraints, but the new version does have them.
Although we can disable the automatic table structure changes in the system configuration, this is still a potential risk point.
Many of our tables now contain over 50 million records.
If the system automatically adds field constraints during startup, it could have an impact on the business operations.
I believe this scenario is quite common. Does Hibernate have a configuration option to avoid adding these constraints and only perform pure data relationship mapping?

If you want to be able control your schema fully, you have to disable hbm2ddl. Also, please note that hbm2ddl UPDATE is not recommended for production environments. Use a schema management tool like Liquibase or Flyway to do migrations.

Then let’s implement the dialect package ourselves, fixing the constraint to return false, as we are a productized system and some deployments are on customer premises over extended periods.

This might actually be necessary, if you have a custom converter for the enum. In this case hibernate should not generate any check clauses imo because hibernate cannot know how the values are converted.

Well, Hibernate ORM could invoke the converter to understand the values that are generated. Either way, if you think you found a bug, please try to create a reproducer with our test case template and if you are able to reproduce the issue, create a bug ticket in our issue tracker and attach that reproducer.