Reputation: 907
I've read some blog posts (eg: http://orapath.blogspot.com.br/2012/04/hibernate.html, http://abramsm.wordpress.com/2008/04/23/hibernate-batch-processing-why-you-may-not-be-using-it-even-if-you-think-you-are/) recomending to set hibernate.jdbc.batch_size configuration property to higher values in order to get better performance at processing batches of inserts/updates.
However, browsing Hibernate 4.1.8 source code I could see that neither the field jdbcBatchSize from org.hibernate.cfg.Settings, nor the corresponding getter getJdbcBatchSize() method that reflect the settings of this property are used throughout the framework.
So is there any reason to configure this setting at all?
Upvotes: 0
Views: 1967
Reputation: 1074
The field Settings.jdbcBatchSize seems to not be used, but the actual configuration is used in other places. I downloaded the source for hibernate-core, and through a textual search could find Environment.STATEMENT_BATCH_SIZEbeing used in some places.
Take a look at org.hibernate.engine.jdbc.batch.internal.BatchBuilderImpl.java
Results from the textual search
Search "STATEMENT_BATCH_SIZE" (23 hits in 22 files)
C:\Documents and Settings\cfweber\Desktop\hibernate\core\org\hibernate\cfg\AvailableSettings.java (1 hit)
Line 190: public static final String STATEMENT_BATCH_SIZE = "hibernate.jdbc.batch_size";
C:\Documents and Settings\cfweber\Desktop\hibernate\core\org\hibernate\cfg\ExternalSessionFactoryConfig.java (1 hit)
Line 281: setUnlessNull( props, Environment.STATEMENT_BATCH_SIZE, jdbcBatchSize );
C:\Documents and Settings\cfweber\Desktop\hibernate\core\org\hibernate\cfg\SettingsFactory.java (1 hit)
Line 114: int batchSize = ConfigurationHelper.getInt(Environment.STATEMENT_BATCH_SIZE, properties, 0);
C:\Documents and Settings\cfweber\Desktop\hibernate\core\org\hibernate\dialect\AbstractTransactSQLDialect.java (1 hit)
Line 125: getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, NO_BATCH);
C:\Documents and Settings\cfweber\Desktop\hibernate\core\org\hibernate\dialect\Cache71Dialect.java (2 hits)
Line 258: getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
Line 259: //getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, NO_BATCH);
C:\Documents and Settings\cfweber\Desktop\hibernate\core\org\hibernate\dialect\CUBRIDDialect.java (1 hit)
Line 76: getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
C:\Documents and Settings\cfweber\Desktop\hibernate\core\org\hibernate\dialect\DB2Dialect.java (1 hit)
Line 177: getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, NO_BATCH );
C:\Documents and Settings\cfweber\Desktop\hibernate\core\org\hibernate\dialect\H2Dialect.java (1 hit)
Line 191: getDefaultProperties().setProperty( AvailableSettings.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
C:\Documents and Settings\cfweber\Desktop\hibernate\core\org\hibernate\dialect\HSQLDialect.java (1 hit)
Line 219: getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
C:\Documents and Settings\cfweber\Desktop\hibernate\core\org\hibernate\dialect\InterbaseDialect.java (1 hit)
Line 59: getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, NO_BATCH);
C:\Documents and Settings\cfweber\Desktop\hibernate\core\org\hibernate\dialect\JDataStoreDialect.java (1 hit)
Line 60: getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
C:\Documents and Settings\cfweber\Desktop\hibernate\core\org\hibernate\dialect\MckoiDialect.java (1 hit)
Line 81: getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, NO_BATCH);
C:\Documents and Settings\cfweber\Desktop\hibernate\core\org\hibernate\dialect\MimerSQLDialect.java (1 hit)
Line 136: getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, "50");
C:\Documents and Settings\cfweber\Desktop\hibernate\core\org\hibernate\dialect\MySQLDialect.java (1 hit)
Line 182: getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE);
C:\Documents and Settings\cfweber\Desktop\hibernate\core\org\hibernate\dialect\Oracle8iDialect.java (1 hit)
Line 200: getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
C:\Documents and Settings\cfweber\Desktop\hibernate\core\org\hibernate\dialect\Oracle9Dialect.java (1 hit)
Line 87: getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE);
C:\Documents and Settings\cfweber\Desktop\hibernate\core\org\hibernate\dialect\PostgreSQL81Dialect.java (1 hit)
Line 154: getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE);
C:\Documents and Settings\cfweber\Desktop\hibernate\core\org\hibernate\dialect\SAPDBDialect.java (1 hit)
Line 136: getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE);
C:\Documents and Settings\cfweber\Desktop\hibernate\core\org\hibernate\dialect\TeradataDialect.java (1 hit)
Line 110: getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, NO_BATCH );
C:\Documents and Settings\cfweber\Desktop\hibernate\core\org\hibernate\dialect\TimesTenDialect.java (1 hit)
Line 84: getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE);
C:\Documents and Settings\cfweber\Desktop\hibernate\core\org\hibernate\engine\jdbc\batch\internal\BatchBuilderImpl.java (1 hit)
Line 55: size = ConfigurationHelper.getInt( Environment.STATEMENT_BATCH_SIZE, configurationValues, size );
C:\Documents and Settings\cfweber\Desktop\hibernate\core\org\hibernate\engine\jdbc\batch\internal\BatchBuilderInitiator.java (1 hit)
Line 55: ConfigurationHelper.getInt( Environment.STATEMENT_BATCH_SIZE, configurationValues, 1 )
Upvotes: 1