I would like to add indexing to my existing Entity, exacly on specific column. Following by documentation i wrote something like that:
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;
(...)
}
But isnt working, the INDEX not created. And I always gotted exception:
Caused by: org.postgresql.util.PSQLException: ERROR: error in syntax or/in near "."
Query created by EclipseLink is
CREATE INDEX myschema.knife ON potatoe (ORIGIN)]]
and i dont know why he change the name of index. Why eclipseLink add schema with dot to name? I suppose that this "." in name of index makeing problem, but I don't know how to delete this.
I'am working on eclipselink ver 2.5.0 and postgresql ver 9.1-901.
edit// When i delete attribute "schema", eclipselink create properly query:
CREATE INDEX knife ON potatoe (ORIGIN)]]
but problem is that i must define schema because I have some. So without defined schema its a error about relation(relation not exisit). So its true, because my default relation isn't "myschema".
I check in Postgres and working query is like below but i dont know how to generate this:
CREATE INDEX knife ON myschema.potatoe (ORIGIN)
Someone have idea?
I could not find indeed the schema defining for table in docs Try a monkey hack:
@Index(name = "knife", columnNames = "origin", table = "myschema.potatoe")