如何在MySQL中使用JPA自动生成区分大小写的列 [英] How to generate case sensitive columns with JPA in MySQL automatically
问题描述
如何在创建时默认命令JPA将MySQL文本内容设置为区分大小写的MySQL数据库列?
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
(可选)在为列生成DDL时使用的SQL片段.
默认为生成的SQL以创建推断类型的列.
默认值:
""
(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:
""
例如,使用@Column注释,您将使用
In your case, for example, using the @Column annotation, you would use
@Column(name ="NAME_COL",columnDefinition ="VARCHAR(250)COLLATE latin1_general_cs") 私有字符串名称;
@Column(name = "NAME_COL", columnDefinition = "VARCHAR(250) COLLATE latin1_general_cs") private String name;
这篇关于如何在MySQL中使用JPA自动生成区分大小写的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!