Skip to content

Files

Latest commit

 

History

History

HibernateSpringBootHiLo

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

How To Generate Sequences Of Identifiers Via Hibernate hi/lo Algorithm

Note: If systems external to your application need to insert rows in your tables then don't rely on hi/lo algorithm since, in such cases, it may cause errors resulted from generating duplicated identifiers. Rely on pooled or pooled-lo algorithms (optimizations of hi/lo).

Description: This is a Spring Boot example of using the hi/lo algorithm for generating 1000 identifiers in 10 database roundtrips for batching 1000 inserts in batches of 30.

Key points:

  • use the SEQUENCE generator type (e.g., in PostgreSQL)
  • configure the hi/lo algorithm as in Author.java entity

Output example:


If you need a deep dive into the performance recipes exposed in this repository then I am sure that you will love my book "Spring Boot Persistence Best Practices"If you need a hand of tips and illustrations of 100+ Java persistence performance issues then "Java Persistence Performance Illustrated Guide" is for you.