Hibernate ID Generator

A cursory search of Google for ‘hibernate custom id generator tutorial’ turned up the following possibilities. I’ve excluded those that don’t look useful and summarized the content of each. http://www.devx.com/Java/Article/30396 – covers the issues of generating an ID before the data is persisted (and hence does not yet have a business key). http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html_single/#mapping-declaration – the … Read more

Composite PRIMARY KEY enforces NOT NULL constraints on involved columns

If you need to allow NULL values, use a UNIQUE constraint (or index) instead of a PRIMARY KEY (and add a surrogate PK column – I suggest a serial or IDENTITY column in Postgres 10 or later). Auto increment table column A UNIQUE constraint allows columns to be NULL: CREATE TABLE distributor ( distributor_id GENERATED … Read more