Quantcast
Viewing all articles
Browse latest Browse all 5

Answer by Vlad Mihalcea for JPA Embeddeble PK and nullable field

Since you must not use null in your PK, this is what you should do:

  1. Add a surrogate primary key.
  2. You can still achieve the uniqueness constraint and the default PK index with a parial index (in PostgreSQL):

    CREATE UNIQUE INDEX style_item_size_idx ON my_table (Style_no, item_no, size_no) WHERE (item_no IS NOT NULL AND size_no IS NOT NULL);


Viewing all articles
Browse latest Browse all 5

Trending Articles