【问题标题】:EclipseLink - adding indexing to PostgressEclipseLink - 向 Postgres 添加索引
【发布时间】:2017-04-12 14:12:43
【问题描述】:

我想将索引添加到我现有的实体中,确切地说是在特定列上。在文档之后我写了类似的东西:

1.first way
@Entity
@Table(name = "potatoe", schema = "mySchema")
public class Potatoe {
(...)
@Index(name = "knife", table = "potatoe", schema = "mySchema")
    private String origin;
(...)
}

2.second way
@Entity
@Table(name = "potatoe", schema = "mySchema")
@Index(name = "knife", columnNames = "origin", table = "potatoe", schema = "mySchema")
public class Potatoe {
(...)
    private String origin;
(...)
}

 3. third way(pure jpa)
    @Entity
    @Table(name = "potatoe", schema = "mySchema", indexes = {@javax.persistence.Index(name = "knife", columnList = "origin")})
    public class Potatoe {
    (...)
        private String origin;
    (...)
    }

但是没有工作,索引没有创建。而且我总是遇到异常:

原因:org.postgresql.util.PSQLException:错误:语法错误 或/在“。”附近

EclipseLink 创建的查询是

在土豆上创建索引 myschema.knife (起源)]]

我不知道他为什么要更改索引的名称。为什么 eclipseLink 添加带有点的模式来命名?我想这个“。”以索引制作问题的名义,但我不知道如何删除它。

我正在开发 eclipselink 2.5.0 版和 postgresql 9.1-901 版。

编辑// 当我删除属性“模式”时,eclipselink 会正确创建查询:

在土豆上创建索引刀 (起源)]]

但问题是我必须定义模式,因为我有一些。因此,如果没有定义的模式,它是关于关系的错误(关系不存在)。所以这是真的,因为我的默认关系不是“myschema”。

我签入 Postgres,工作查询如下所示,但我不知道如何生成:

在 myschema.potatoe (ORIGIN) 上创建索引刀

有人知道吗?

【问题讨论】:

  • 似乎是一个错误 - 索引不应该有模式名称前缀,但表应该 - 一直在
  • 也许可以试试@Index(name = "knife", columnNames = "origin", table = "potatoe") ?..
  • @Vao Tsun 我尝试了我认为注释的各种变体,但都没有工作:/
  • 都出现同样的错误?..
  • 不完全是,当我没有定义架构时,错误是“与 nameOfDatabase 无关”。它出现是因为我的默认架构不是“mySchema”,否则错误是相同的。

标签: java postgresql jpa eclipselink


【解决方案1】:

我确实找不到 schema defining for table in docs 试试猴子黑客:

@Index(name = "knife", columnNames = "origin", table = "myschema.potatoe")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-08-04
    • 1970-01-01
    • 1970-01-01
    • 2022-08-04
    • 2014-09-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多