java - 如何强制 Eclipse Link 创建完全相同的 ClassName 的表?

标签 java eclipse jpa orm eclipselink

我希望 JPA EclipseLink 完全按照 ClassName(和字段)创建表,而无需注释 @Table 和 @Column。它总是使用大写创建表和字段,这使得数据库控制台的可读性变得困难。

例如:

@Entity
public class ChannelEntity {
    
    @Id     @GeneratedValue  
    public Long id;
    
    public String name;
    
    public String description;
    
    public Boolean oficial;

    @Temporal(TemporalType.TIMESTAMP)
    public Date creation;

}

我想要结果

    Table: ChannelEntity
    id  creation    description name        oficial
   ----------------------------------------------------
    351 NULL        meu desc    meu nome    1

也许 persistence.xml 中存在相同的参数,但我找不到它。

最佳答案

如果 EclipseLink 运行正常,则您要查找的参数为 delimited-identifers 。来自 JPA 2.1 规范:

It is possible to specify that all database identifiers in use for a persistence unit be treated as delimited identifiers by specifying the <delimited-identifiers/> element within the persistence-unit-defaults element of the object/relational xml mapping file. If the <delimited-identifiers/> element is specified, it cannot be overridden.

如果包含此元素,EclipseLink 应在其生成的 SQL 中分隔所有数据库标识符,这将导致使用区分大小写的名称创建数据库对象。

关于java - 如何强制 Eclipse Link 创建完全相同的 ClassName 的表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41066606/

相关文章:

java - 如何在 Java 中使用 SVM

java - 有没有人有任何使用 Eclipse GMF 的经验?

java - Spring:我应该在两者之间添加 @Transactional 注释吗?

java - 尝试使用 Eclipse WindowBuilder,但 ActionLister 没有执行任何操作

java - 如何取消正在运行的 SQL 查询?

java - 如何分割字符串并保留特定的分隔符?

java - 用于 jaxws-maven-plugin 下载问题的 m2e 连接器

c++ - Eclipse C/C 函数 'printf' 无法解析

database - JPA - 左连接 2 个没有关联的表

java - 使用额外的列标准问题 hibernate 多对多