hibernate.jdbc.batch_size

In this section, you will learn about the hibernate.jdbc.batch_size of the hibernate.cfg.xml.

hibernate.jdbc.batch_size

hibernate.jdbc.batch_size

In this section, you will learn about the hibernate.jdbc.batch_size of the hibernate.cfg.xml.

The sample hibernate.cfg.xml file is given below :

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://192.168.10.13:3306/anky</property>
<property name="connection.username">root</property>
<property name="connection.password">root</property>

<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.jdbc.batch_size">50</property>

<!-- List of mapping classes -->
<mapping class="net.roseindia.Address" />
<mapping class="net.roseindia.Employee" />

</session-factory>
</hibernate-configuration>

The hibernate.jdbc.batch_size is used to define the batch size. In the above hibernate.cfg.xml, the batch size is set to 50.

In the batch update, multiple update queries are sending  in a single batch to the database table. The hibernate.jdbc.batch_size property tag define the batch size. In the above hibernate.cfg.xml, we set the batch size to 50.

You can relate the batch update as sending 50 files in zipped folder than sending 50 files individually.

If the batch size is higher then you need more memory . If the batch size is low, you need more round trips to the database.