Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.