3.2.2.5. Preserve the Existing Behavior of the Hibernate Identity Auto Generated Value

Hibernate 3.5 introduced a core property named hibernate.id.new_generator_mappings that directs how identity or sequence columns are generated when using @GeneratedValue. In JBoss EAP 6, the default value for this property is set as follows:
  • When you deploy a native Hibernate application, the default value is false.
  • When you deploy a JPA application, the default value is true.
Guidelines for New Applications

New applications that use the @GeneratedValue annotation should set the value for the hibernate.id.new_generator_mappings property to true. This is the preferred setting because it is more portable across different databases. In most cases it is more efficient and, in some cases, it addresses compatibility with the JPA 2 specification.

  • For new JPA applications, JBoss EAP 6 defaults the hibernate.id.new_generator_mappings property to true and it should not be changed.
  • For new native Hibernate applications, JBoss EAP 6 defaults the hibernate.id.new_generator_mappings property to false. You should set this property to true.
Guidelines for Existing JBoss EAP 5 Applications

Existing applications that use the @GeneratedValue annotation should make sure that the same generator is used to create primary key values for new entities when the application is migrated to JBoss EAP 6.

  • For existing JPA applications, JBoss EAP 6 defaults the hibernate.id.new_generator_mappings property to true. You should set this property to false in the persistence.xml file.
  • For existing native Hibernate applications, JBoss EAP 6 defaults the hibernate.id.new_generator_mappings to false and it should not be changed.
For more information about these property settings, see Section 3.2.2.3, “Persistence Unit Properties”.