[英]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.