简体   繁体   English

使用EclipseLink将@Table和@Column的命名策略更改为小写

[英]Changing naming strategy of @Table and @Column with EclipseLink to lower-case

When defining a JPA Entity like this: 在定义这样的JPA实体时:

@Entity
@Table
public class CaseExample implements Serializable {
    @Id
    Long id;
    @Basic
    String fooBar;
}

the automatically created SQL table name is "CASEEXAMPLE" and the column name "FOOBAR". 自动创建的SQL表名称为“ CASEEXAMPLE”,列名称为“ FOOBAR”。 How can I change that from upper-case to lower-case-with-underscore eg "case_example" and "foo_bar" without having to add a name="foo_bar" to every single @Table and @Column? 如何将其从大写改为带小写的下划线,例如“ case_example”和“ foo_bar”, 不必在每个@Table和@Column上添加名称=“ foo_bar”?

Is the naming strategy defined by JPA or implemenation dependend? JPA或实现依赖定义了命名策略吗? I use JPA 2.0 with EclipseLink 2.5.0. 我将JPA 2.0与EclipseLink 2.5.0一起使用。

JPA standardizes the names. JPA将名称标准化。 I would leave them using the standard, or use @Column to change specific ones. 我将使用标准保留它们,或使用@Column更改特定的。

With EclipseLink you could modify you column names using your own code in a DescriptorCustomizer or SessionCustomizer. 使用EclipseLink,您可以在DescriptorCustomizer或SessionCustomizer中使用自己的代码来修改列名称。 You would just iterate over your descriptor's mapping and reset the fieldNames based on your naming convention. 您只需要遍历描述符的映射并根据命名约定重置fieldNames。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为一个 class 设置命名策略为小驼峰式 - Set naming strategy to lower camel case for one class Hibernate命名策略更改表名 - Hibernate naming strategy changing table names 正则表达式搜索小写的Enum常量 - Regex to search for lower-case Enum constants 是否有既不大写也不小写的Unicode字母? - Are there Unicode Letters which are neither upper- nor lower-case? 如何在Java中创建同时支持大写和小写E作为指数分隔符的NumberFormat? - How to create a NumberFormat in Java that supports both an upper-case and a lower-case E as an Exponent Separator? 如何查找前三个字符串,它们以小写字母“a”开头,并按排序顺序 - How to find the first three strings, which start with a lower-case `a` in a sorted order 当文档以小写开头时,空手道 HTML 解析抛出 SaxException - Karate HTML parsing throwing SaxException when document begins with lower-case <!doctype 如何只取小写字母和数字并将它们放在单独的 TextField 中? - How to take only lower-case letters and numbers and put them in separate TextFields? 将列表中的单词更改为小写 - Changing words in list to lower case Spring 1.4.0版本的休眠命名策略将在表名和列名中添加下划线(_) - Spring 1.4.0 release hibernate naming strategy will add underscore(_) to table and column names
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM