使用EclipseLink将@Table和@Column的命名策略更改为小写 [英] Changing naming strategy of @Table and @Column with EclipseLink to lower-case

查看:103
本文介绍了使用EclipseLink将@Table和@Column的命名策略更改为小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在定义这样的JPA实体时:

When defining a JPA Entity like this:

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

自动创建的SQL表名称为"CASEEXAMPLE",列名称为"FOOBAR". 如何将其从带下划线的大写更改为小写,例如"case_example"和"foo_bar"是否不必为每个@Table和@Column添加名称="foo_bar"?

the automatically created SQL table name is "CASEEXAMPLE" and the column name "FOOBAR". How can I change that from upper-case to lower-case-with-underscore e.g. "case_example" and "foo_bar" without having to add a name="foo_bar" to every single @Table and @Column?

JPA或实现依赖定义了命名策略吗?我将JPA 2.0与EclipseLink 2.5.0一起使用.

Is the naming strategy defined by JPA or implemenation dependend? I use JPA 2.0 with EclipseLink 2.5.0.

推荐答案

JPA将名称标准化.我将保留它们使用标准,或使用@Column更改特定的.

JPA standardizes the names. I would leave them using the standard, or use @Column to change specific ones.

使用EclipseLink,您可以在DescriptorCustomizer或SessionCustomizer中使用自己的代码来修改列名称.您只需遍历描述符的映射并根据命名约定重设fieldNames.

With EclipseLink you could modify you column names using your own code in a DescriptorCustomizer or SessionCustomizer. You would just iterate over your descriptor's mapping and reset the fieldNames based on your naming convention.

这篇关于使用EclipseLink将@Table和@Column的命名策略更改为小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆