[Hibernate] Access cache memory before committing bits

I want to access cache before batch commit in Hibernate. I count users to BATCH_SIZE, then

if (countUsers == BATCH_SIZE) { countUsers = 0; session.flush(); session.clear(); transaction.commit(); session = HibernateUtil.getSessionFactory() .getCurrentSession(); transaction = session.beginTransaction(); } 

What I do, I store 30 lines in cahce and then save them in the database. but I also want to get information about these cached lines before storing them in the database.

How to do it?

+6
source share
1 answer

all you need to set the hibernates jdbc batch size attribute and be sure of transaction management

 hibernate.jdbc.batch_size=50 

you can see my previuos post on this subject

0
source

Source: https://habr.com/ru/post/899394/


All Articles