# Generate ddl every time at startup

**URL:** <https://discourse.hibernate.org/t/generate-ddl-every-time-at-startup/8004>\
**Category:** Hibernate ORM\
**Created:** [July 23, 2023, 6:41am UTC](https://discourse.hibernate.org/t/generate-ddl-every-time-at-startup/8004 "2023-07-23T06:41:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rxxy](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/rxxy/32/2116_2.png) [@rxxy](https://discourse.hibernate.org/u/rxxy)\
**Post date:** [July 23, 2023, 6:41am UTC](https://discourse.hibernate.org/t/generate-ddl-every-time-at-startup/8004/1 "2023-07-23T06:41:50Z")

</div>

like this, The ddl is applied every time the application starts, even if the table structure has not changed.

```auto
alter table sys_user modify column sex enum ('FEMALE','MALE')

```

configuration:

```auto
hibernate.hbm2ddl.auto=update

```

database: mysql8.0  
driver: mysql8.0  
hibernate: 6.2.2

After debugging and troubleshooting, I found that the real column size is inconsistent with the column size in the entity class, so every time I modify the table structure.

The enumeration column size returned by mysql driver is 6，hibernate the column size is calculated by the default value of the varchar type, 255,255 and 6 are not equal, so each time the alter.

In fact, I think enumeration types do not need to judge whether the size is consistent, and this problem will also occur in datetime and bigint, datetime I handled this problem through custom dialect. I also don’t know how mysql calculates the column size for enumeration and bigint types, because he read the data in the information\_schema.column table.

see also  
org.hibernate.tool.schema.internal.ColumnDefinitions#hasMatchingLength

---

<div class="post-metadata">

**Author:** ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)\
**Post date:** [July 24, 2023, 10:30am UTC](https://discourse.hibernate.org/t/generate-ddl-every-time-at-startup/8004/2 "2023-07-24T10:30:28Z")

</div>

Did you try updating to Hibernate 6.2.7.Final yet?

---

<div class="post-metadata">

**Author:** ![rxxy](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/rxxy/32/2116_2.png) [@rxxy](https://discourse.hibernate.org/u/rxxy)\
**Post date:** [July 25, 2023, 1:27am UTC](https://discourse.hibernate.org/t/generate-ddl-every-time-at-startup/8004/3 "2023-07-25T01:27:43Z")

</div>

6.2.7.Final version this problem still exists

---

<div class="post-metadata">

**Author:** ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)\
**Post date:** [July 25, 2023, 6:36am UTC](https://discourse.hibernate.org/t/generate-ddl-every-time-at-startup/8004/4 "2023-07-25T06:36:16Z")

</div>

In that case, please create an issue in the issue tracker([https://hibernate.atlassian.net](https://hibernate.atlassian.net)) with a test case([https://github.com/hibernate/hibernate-test-case-templates/blob/master/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/JPAUnitTestCase.java](https://github.com/hibernate/hibernate-test-case-templates/blob/master/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/JPAUnitTestCase.java)) that reproduces the issue.

---

<div class="post-metadata">

**Author:** ![rxxy](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/rxxy/32/2116_2.png) [@rxxy](https://discourse.hibernate.org/u/rxxy)\
**Post date:** [July 29, 2023, 6:14am UTC](https://discourse.hibernate.org/t/generate-ddl-every-time-at-startup/8004/5 "2023-07-29T06:14:38Z")

</div>

ok，issue is created.  
[https://hibernate.atlassian.net/browse/HHH-17011](https://hibernate.atlassian.net/browse/HHH-17011)
