Currently, if the ` {{ hibernate.id.new_generator_mappings ` }} is set to ` {{ false ` }} , ` {{ @GeneratedValue(strategy = GenerationType.AUTO) ` }} is mapped to ` {{ native ` }} . If this property is ` {{ true ` }} (which is the deafult value in 5.x), the ` {{ @GeneratedValue(strategy = GenerationType.AUTO) ` }} is always mapped to ` {{ SequenceStyleGenerator ` }} .
For this reason, on any database that does not support sequences natively (e.g. MySQL) we are going to use the ` {{ TABLE ` }} generator instead of ` {{ IDENTITY ` }} .
However, ` {{ TABLE ` }} generator, although more portable, uses a separate transaction every time a value is being fetched from the database. In fact, even if the ` {{ IDENTITY ` }} disables JDBC batch updates and the ` {{ TABLE ` }} generator uses the pooled optimizer, the ` {{ IDENTITY ` }} still scales better.
!MySQLIdentityVsTable.png|thumbnail! |
|