The default identifier generator for Postgresql in Hibernate is SequenceGenerator [1]. that is, Hibernate will perform a SELECT nextval('hibernate_sequence') to generate an identifier before executing INSERT foo (id, ...) VALUES (123, ...) when committing the session.
However, PostgreSql supports columns of auto-increment identifiers (see, for example, [2]), and the default generator for all other databases that support auto-increment use this function [3], as well as insert without an id value and query databases for new identifier (before the session commit, but in the session transaction).
I saw a recent discussion [4] suggesting that the former strategy be better overall because of insert-to-session mismatch.
If SequenceGenerator is better (according to [4]), why is this not the default for databases that support it (see [3])?
If IdentityGenerator is better, why does PostgreSql explicitly select a SequenceGenerator when Postgres supports the first (according to [2])?
I tried to find the history of the solution to override the default value in the Postgres dialect (see [1]), but I could not find the appropriate commit on GitHub. I returned the code back to the SVN repository, but the trace caught a cold when the PostgreSQLDialect file was added to r11563 with a useless message saying "maven migration" was committed [5]. It seems I can no longer follow the story. Can someone find the commit that added this override? Perhaps there is more information in the commit message.
Thanks in advance.
[1] https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQL81Dialect.java#L267
[2] PostgreSQL autorun
[3] https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java#L639
[4] http://nhforge.org/blogs/nhibernate/archive/2009/03/20/nhibernate-poid-generators-revealed.aspx
[5] https://source.jboss.org/browse/Hibernate/core/trunk/core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java?focusedRev=14993&fromRev=11563&toRev=14993#r14993