Hibernate Batch Insert, Batch Update

I have a dao that basically inserts a record into a table using hibernate, that dao is marked with @Transactional annotation using propogation-NESTED , and I have a service that creates some other things and then calls my dao. My service is also annotated with @Transactional using propagation-REQUIRED .

I call the service in a loop. My inserts on my dao work in batch mode or one by one? How can I be sure that they work in batch mode? Does hibernateTransaction manager manage batch inserts?

I am using Oracle DB.

0
source share
4 answers

I set the following property and my productivity increased;

 hibernate.jdbc.batch_size=50 
+1
source

I am not a Hibernate expert, but I remember adding a property to exit the SQL statements.

  SessionFactory sf = new Configuration() .setProperty("hibernate.show_sql", "true") 

This should show which sql is created after each execution of your method.

0
source

It will not go in batch mode, see the Hibernate Doc .

0
source

To keep track of whether hibernate uses packages, you can create a logger for org.hibernate.jdbc.AbstractBatcher, it will record the dispenser ...

0
source

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


All Articles