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 in the database. I want to minimize hand editing of the DDL (I realize that some will have to happen).
Anyone know how I should go about this? I realize that I can make all Strings VARCHARS or CHARS via a hacked dialect, but that isn't what is always appropriate in the database.
I would like to be able to do this with annotations or aop, avoiding custom column definition text in my classes.
Thanks.
Annotate the strings you want to map to a CHAR in the database with
@Column(columnDefinition="CHAR(<your-char-length>)")
.