Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exactly does Hibernate new_generator_mappings actually do?

New to Spring Boot/JPA/Hibernate and I'm trying to understand what the hibernate.id.new_generator_mappings property actually does.

According to that doc, it:

"...directs how identity or sequence columns are generated when using @GeneratedValue"

But it doesn't really explain the behavioral difference from when its true vs when its false. Any ideas?

like image 790
smeeb Avatar asked Apr 06 '17 19:04

smeeb


1 Answers

This ‘hibernate.id.new_generator_mappings’ by default is false which uses the ‘SequenceHiLoGenerator‘ which will have that multiply behavior. Once we set it to true, it will then use the ‘SequenceStyleGenerator‘, which is more jpa and oracle friendly. It generates identifier values based on an sequence-style database structure. Variations range from actually using a sequence to using a table to mimic a sequence.

Source: https://vcfvct.wordpress.com/2016/04/23/jpa-sequencegenerator-with-allocationsize-1-performance-tuning/

like image 62
gabriel Avatar answered Oct 02 '22 13:10

gabriel