How can I order JPA to set a MySQL database column with text content as case sensitive by default upon creation?
解决方案
The @Column annotation on your field can specify a columnDefinition attribute which may allow you to specify a case-sensitive collation for the column.
public abstract String columnDefinition
(Optional) The SQL fragment that is used when generating the DDL for the column.
Defaults to the generated SQL to create a column of the inferred type.
Default:
""
In your case, for example, using the @Column annotation, you would use
@Column(name = "NAME_COL", columnDefinition = "VARCHAR(250) COLLATE latin1_general_cs")
private String name;