java - Creating date_trunc index via Hibernate 4.3.5 / JPA 2.1 -
i want create index below:
create index idx_foo_req_date on foo using btree (date_trunc('day'::text, req_date)); how/can create via java hibernate annotations?
i have read @index annotation use like:
@table(name = "foo", indexes = { @index(name = "idx_foo_req_date", columnlist = "req_date") }) but create smth this:
create index idx_foo_req_date on foo using btree (req_date); update:
i thought maybe pretty flexible , simple , have tried:
@table(name = "foo", indexes = { @index(name = "idx_foo_req_date", columnlist = "date_trunc('day'::text, req_date)") }) however org.hibernate.annotationexception has been thrown, complaining columns in columnlist.
hibernate uses jpa @index annotation doesn't support function-based indexes.
you'd better use flyway , keep schema migration in incremental scripts.
Comments
Post a Comment