13 Replies Latest reply on Jun 6, 2007 8:35 PM by Alexander Sack

    Primary key generator best practices? (Postgres specific)

    Alexander Sack Novice

      Guys, we are using postgres 8.1.3 for our application and running into a lot of problems - mainly dealing with primary key management. I have tracked down one issue in that our current configuration does not use the autovacuum stuff in postgres to cleanup the database over a lot of transactions.

      But the other issue which is semi related is that EJB3/Hibernate is not dealing with the primary keys correctly? We have instances where EJB3/Hibernate tries to insert a new entity over an already existing primary key? i.e. EJB3/Hibernate does not get the next key properly. All of our tables are using AUTO for primary key generation.

      Question, should we be specifing our own generator function? Should we be using @SequenceGenerator annotatoin instead of just relying on AUTO?

      (on a side note, how do I specify a generic generator function across multiple tables using annotations?)

      Any advice would come much appreciated!

      Thanks!