Hibernate GenerationType.AUTO dialect overview

When using Hibernate it quickly comes to the point, where you have to decide how your @Id attribute of your entity should be generated. JPA offers four possible options

  • AUTO

For a description of these see the Javadoc of GenerationType.

If you have decided to take IDENTITY or SEQUENCE in the past, this can be a problem when supporting new databases in the future. Sadly, most of the databases don’t support both GenerationTypes. That is a bummer, because you have to decide early during development which GenerationType to choose. No matter which you’ve chosen, it’s the wrong one if it’s not TABLE or AUTO :).

If you now think, simply changing the GenerationType to AUTO fixes the problem, you can get into serious trouble! Continue reading …