My application is JPA/Hibernate, and uses H2 for unit tests and PostgreSQL for deployment.
I have the following JPA entity:
@Entity
@Table(uniqueConstraints=@UniqueConstraint(name="review_createdby_key", columnNames={"review_poid","createdby"}))
public class ReviewVote implements CreateUpdateAware, Serializable {
...
Which when built into a Postgres table using JPA/Hibernate produces the following:
Column | Type | Modifiers
-------------+-----------------------------+-----------------------------------------------------------
poid | bigint | not null default nextval('reviewvote_poid_seq'::regclass)
created | timestamp without time zone |
createdby | bigint | not null
type | character varying(255) | not null
updated | timestamp without time zone |
review_poid | bigint | not null
Indexes:
"reviewvote_pkey" PRIMARY KEY, btree (poid)
Foreign-key constraints:
"fk5ce2e827ac213e" FOREIGN KEY (review_poid) REFERENCES moderatable(poid)
Note that there is no unique constraint as defined in the @Table annotation.
The funny thing is that when running the unit tests the unique constraint is created, its just in Postgres that it is not working
Any ideas as to why this may be?
Cheers! NFV