Skip to content

Files

Latest commit

 

History

History

HibernateSpringBootPooledLo

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

How To Generate Sequences Of Identifiers Via Hibernate pooled-lo Algorithm

Note: Rely on pooled-lo or pooled especially if, beside your application, external systems needs to insert rows in your tables. Don't rely on hi/lo since, in such cases, it may cause errors resulted from generating duplicated identifiers.

Description: This is a Spring Boot example of using the pooled-lo algorithm. The pooled-lo is an optimization of hi/lo similar with pooled. Only that, the strategy of this algorithm fetches from the database the current sequence value and use it as the in-memory lowest boundary identifier. The number of in-memory generated identifiers is equal to increment_size.

Key points:

  • use the SEQUENCE generator type (e.g., in PostgreSQL)
  • configure the pooled-lo algorithm as in Author.java entity
  • insert a few records via pooled-lo
  • insert a few records natively (this acts as an external system that relies on NEXTVAL('hilo_sequence') and is not aware of pooled-lo presence and/or behavior)

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.