JPA/Hibernate DDL generation; CHAR vs. VARCHAR

前端 未结 2 410
执念已碎
执念已碎 2020-12-31 11:29

I have a JPA/Hibernate data model that I am using the Hibernate hbm2ddl tool to generate database DDL. I have some strings that should be CHAR and some that may be VARCHAR i

2条回答
  •  孤城傲影
    2020-12-31 12:09

    So, I finally found that you can specify a length limit for a type in the dialect. So, I've decided that anything under a length of 10 should be char and anything over that should be varchar:

    registerColumnType( Types.VARCHAR, 10, "char($l)" );
    

    That isn't exactly what I was wanting, but that is good enough. Sad that I didn't find that earlier.

提交回复
热议问题