0 Replies Latest reply on Jun 7, 2007 5:08 PM by Alexander Sack

    SequenceGenerator issue within JPA/Hibernate3 strategy=AUTO?

    Alexander Sack Novice

      So after spending some time with Hibernate3 source and debugging our postgres database (8.1.3), it seems that the PostgresDialect class sets its default IdentifierGenerator to a SequenceGenerator (makes sense since Postgres uses SERIAL types).

      Now, for EJB3 style @GeneratedId, the default strategy is AUTO which according to the HibernateExt annotation processor dwindles into a "native" which eventually leads the EntityPersister handling these entities (such as the SingleTablePersister) to use the SequenceGenerator. Fine, but when the SequenceGenerator is configured, it creates a sequence called "hibernate_sequence" which is used to basically generate values (1,2,3 so on).

      It seems to me that if I have all my entities as AUTO then Hibernate3 uses the ONE hibernate_sequence variable to generate primary keys across tables! Is that true? That just seems nuts to me. I would in fact believe that AUTO would turn into SEQUENCE and create a per table, table_column_seq variable to manage primary keys.

      I've debugged this now over two days since Hibernate3 is new to me. Can someone who is knowledgeable with the source (and not dangerous like myself) comment on my observation? Is this really true?

      Thanks!

      PS Wasn't sure if this should go in the Hibernate users group or design but I am technically asking a design question with respect to my user issue!