I've read the forum/searched high and low but this will just not batch as I would expect. In short I want Insert into foo values (...), (...), (...) to batch up the insert into one statement. Postgres 9. Hibernate 3.4.0. JPA 1.99 The entity has no relationships to other entities / collections, it is all by itself it is versioned, and uses GenerationType.SEQUENCE
Here is what the internet says should activate this feature. <property name="hibernate.jdbc.batch_size" value="50"/> <property name="hibernate.cache.use_query_cache" value="false"/> <property name="hibernate.cache.use_second_level_cache" value="false"/> <property name="hibernate.cache.use_structured_entries" value="true"/> <property name="hibernate.jdbc.use_streams_for_binary" value="false"/> <property name="hibernate.jdbc.batch_versioned_data" value="true"/> <property name="hibernate.order_inserts" value="true"/> <property name="hibernate.order_updates" value="true"/>
In Java, Inside my @Transactional, I call .merge on that type of entity and only that type. I've also tried calling persist, and disabling versioning… no luck… I note this in the logs: AbstractBatcher: - no batched statements to execute Any help?
Here is some relevant debug trace… reduced for simplicity...
2011-03-31 14:20:37,414 TRACE [pool-2-thread-3] AbstractSaveEventListener: - transient instance of: com.xxx.TimeSeriesEntity 2011-03-31 14:20:37,414 TRACE [pool-2-thread-3] DefaultPersistEventListener: - saving transient instance 2011-03-31 14:20:37,414 DEBUG [pool-2-thread-3] AbstractSaveEventListener: - generated identifier: 188032722, using strategy: org.hibernate.id.SequenceHiLoGenerator 2011-03-31 14:20:37,414 TRACE [pool-2-thread-3] AbstractSaveEventListener: - saving [com.xxx.TimeSeriesEntity#188032722] 2011-03-31 14:20:37,414 TRACE [pool-2-thread-3] Versioning: - using initial version: 0 2011-03-31 14:20:37,414 TRACE [pool-2-thread-3] AbstractFlushingEventListener: - flushing session 2011-03-31 14:20:37,414 DEBUG [pool-2-thread-3] AbstractFlushingEventListener: - processing flush-time cascades //snip 2011-03-31 14:20:37,414 TRACE [pool-2-thread-3] Cascade: - processing cascade ACTION_PERSIST_ON_FLUSH for: com.xxx.TimeSeriesEntity 2011-03-31 14:20:37,414 TRACE [pool-2-thread-3] Cascade: - done processing cascade ACTION_PERSIST_ON_FLUSH for: com.xxx.TimeSeriesEntity //snip 2011-03-31 14:20:37,415 DEBUG [pool-2-thread-3] AbstractFlushingEventListener: - dirty checking collections 2011-03-31 14:20:37,415 TRACE [pool-2-thread-3] AbstractFlushingEventListener: - Flushing entities and processing referenced collections 2011-03-31 14:20:37,415 TRACE [pool-2-thread-3] AbstractEntityPersister: - com.xxx.TimeSeriesEntity.seriesStartTime is dirty 2011-03-31 14:20:37,415 TRACE [pool-2-thread-3] DefaultFlushEntityEventListener: - Updating entity: [com.xxx.TimeSeriesEntity#188032673] 2011-03-31 14:20:37,415 TRACE [pool-2-thread-3] Versioning: - Incrementing: 0 to 1 //snip 2011-03-31 14:20:37,418 TRACE [pool-2-thread-3] AbstractFlushingEventListener: - Processing unreferenced collections 2011-03-31 14:20:37,418 TRACE [pool-2-thread-3] AbstractFlushingEventListener: - Scheduling collection removes/(re)creates/updates 2011-03-31 14:20:37,418 DEBUG [pool-2-thread-3] AbstractFlushingEventListener: - Flushed: 50 insertions, 50 updates, 0 deletions to 50 objects 2011-03-31 14:20:37,418 DEBUG [pool-2-thread-3] AbstractFlushingEventListener: - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections //snip 2011-03-31 14:20:37,419 TRACE [pool-2-thread-3] AbstractFlushingEventListener: - executing flush 2011-03-31 14:20:37,419 TRACE [pool-2-thread-3] ConnectionManager: - registering flush begin 2011-03-31 14:20:37,419 TRACE [pool-2-thread-3] AbstractEntityPersister: - Inserting entity: [com.xxx.TimeSeriesEntity#188032673] 2011-03-31 14:20:37,419 TRACE [pool-2-thread-3] AbstractEntityPersister: - Version: 0 2011-03-31 14:20:37,419 DEBUG [pool-2-thread-3] AbstractBatcher: - about to open PreparedStatement (open PreparedStatements: 0, globally: 1) 2011-03-31 14:20:37,419 DEBUG [pool-2-thread-3] SQL: - insert into timeseries (calc_type, channel_id, counts, data_value, granularity, highest_valid_data_time, max_value, min_value, series_end_time, series_start_time, version, series_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) 2011-03-31 14:20:37,419 TRACE [pool-2-thread-3] AbstractBatcher: - preparing statement 2011-03-31 14:20:37,419 TRACE [pool-2-thread-3] AbstractEntityPersister: - Dehydrating entity: [com.xxx.TimeSeriesEntity#188032673] 2011-03-31 14:20:37,419 TRACE [pool-2-thread-3] LongType: - binding '52283' to parameter: 2 2011-03-31 14:20:37,419 TRACE [pool-2-thread-3] IntegerType: - binding '0' to parameter: 11 2011-03-31 14:20:37,419 TRACE [pool-2-thread-3] LongType: - binding '188032673' to parameter: 12 2011-03-31 14:20:37,419 TRACE [pool-2-thread-3] AbstractEntityPersister: - Inserting entity: [com.xxx.TimeSeriesEntity#188032674] 2011-03-31 14:20:37,420 TRACE [pool-2-thread-3] AbstractEntityPersister: - Version: 0 2011-03-31 14:20:37,420 DEBUG [pool-2-thread-3] AbstractBatcher: - reusing prepared statement 2011-03-31 14:20:37,420 DEBUG [pool-2-thread-3] SQL: - insert into timeseries (calc_type, channel_id, counts, data_value, granularity, highest_valid_data_time, max_value, min_value, series_end_time, series_start_time, version, series_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) //snip 2011-03-31 14:20:37,478 DEBUG [pool-2-thread-3] AbstractBatcher: - Executing batch size: 50 2011-03-31 14:20:37,506 DEBUG [pool-2-thread-3] AbstractBatcher: - no batched statements to execute 2011-03-31 14:20:37,506 DEBUG [pool-2-thread-3] AbstractBatcher: - about to close PreparedStatement (open PreparedStatements: 1, globally: 2) 2011-03-31 14:20:37,506 TRACE [pool-2-thread-3] AbstractBatcher: - closing statement 2011-03-31 14:20:37,506 TRACE [pool-2-thread-3] ConnectionManager: - registering flush end 2011-03-31 14:20:37,506 TRACE [pool-2-thread-3] AbstractFlushingEventListener: - post flush 2011-03-31 14:20:37,507 TRACE [pool-2-thread-3] VersionValue: - version unsaved-value strategy UNDEFINED 2011-03-31 14:20:37,507 TRACE [pool-2-thread-3] IdentifierValue: - id unsaved-value: 0 2011-03-31 14:20:37,507 TRACE [pool-2-thread-3] AbstractSaveEventListener: - transient instance of: com.xxx.TimeSeriesEntity 2011-03-31 14:20:37,507 TRACE [pool-2-thread-3] DefaultPersistEventListener: - saving transient instance 2011-03-31 14:20:37,507 DEBUG [pool-2-thread-3] AbstractSaveEventListener: - generated identifier: 188032723, using strategy: org.hibernate.id.SequenceHiLoGenerator 2011-03-31 14:20:37,507 TRACE [pool-2-thread-3] AbstractSaveEventListener: - saving [com.xxx.TimeSeriesEntity#188032723] 2011-03-31 14:20:37,507 TRACE [pool-2-thread-3] Versioning: - using initial version: 0 2011-03-31 14:20:37,507 TRACE [pool-2-thread-3] VersionValue: - version unsaved-value strategy UNDEFINED 2011-03-31 14:20:37,507 TRACE [pool-2-thread-3] IdentifierValue: - id unsaved-value: 0 2011-03-31 14:20:37,507 TRACE [pool-2-thread-3] AbstractSaveEventListener: - transient instance of: com.xxx.TimeSeriesEntity 2011-03-31 14:20:37,507 TRACE [pool-2-thread-3] DefaultPersistEventListener: - saving transient instance 2011-03-31 14:20:37,507 DEBUG [pool-2-thread-3] AbstractSaveEventListener: - generated identifier: 188032724, using strategy: org.hibernate.id.SequenceHiLoGenerator 2011-03-31 14:20:37,507 TRACE [pool-2-thread-3] AbstractSaveEventListener: - saving [com.xxx.TimeSeriesEntity#188032724] 2011-03-31 14:20:37,507 TRACE [pool-2-thread-3] Versioning: - using initial version: 0 2011-03-31 14:20:37,507 TRACE [pool-2-thread-3] VersionValue: - version unsaved-value strategy UNDEFINED 2011-03-31 14:20:37,507 TRACE [pool-2-thread-3] IdentifierValue: - id unsaved-value: 0
Here is the session factory init:
2011-03-31 14:16:17,521 INFO [SpringOsgiExtenderThread-46] InjectedDataSourceConnectionProvider: - Using provided datasource 2011-03-31 14:16:17,535 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - RDBMS: PostgreSQL, version: 9.0.2 2011-03-31 14:16:17,535 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 9.0 JDBC4 (build 801) 2011-03-31 14:16:17,560 INFO [SpringOsgiExtenderThread-46] Dialect: - Using dialect: org.hibernate.dialect.PostgreSQLDialect 2011-03-31 14:16:17,564 INFO [SpringOsgiExtenderThread-46] TransactionFactoryFactory: - Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory 2011-03-31 14:16:17,564 INFO [SpringOsgiExtenderThread-46] TransactionManagerLookupFactory: - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended) 2011-03-31 14:16:17,565 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - Automatic flush during beforeCompletion(): disabled 2011-03-31 14:16:17,565 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - Automatic session close at end of transaction: disabled 2011-03-31 14:16:17,565 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - JDBC batch size: 50 2011-03-31 14:16:17,565 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - JDBC batch updates for versioned data: enabled 2011-03-31 14:16:17,565 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - Scrollable result sets: enabled 2011-03-31 14:16:17,565 DEBUG [SpringOsgiExtenderThread-46] SettingsFactory: - Wrap result sets: disabled 2011-03-31 14:16:17,565 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - JDBC3 getGeneratedKeys(): enabled 2011-03-31 14:16:17,565 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - Connection release mode: auto 2011-03-31 14:16:17,566 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - Default batch fetch size: 1 2011-03-31 14:16:17,566 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - Generate SQL with comments: disabled 2011-03-31 14:16:17,566 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - Order SQL updates by primary key: enabled 2011-03-31 14:16:17,566 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - Order SQL inserts for batching: enabled 2011-03-31 14:16:17,566 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory 2011-03-31 14:16:17,567 INFO [SpringOsgiExtenderThread-46] ASTQueryTranslatorFactory: - Using ASTQueryTranslatorFactory 2011-03-31 14:16:17,567 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - Query language substitutions: {} 2011-03-31 14:16:17,567 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - JPA-QL strict compliance: enabled 2011-03-31 14:16:17,567 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - Second-level cache: disabled 2011-03-31 14:16:17,567 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - Query cache: disabled 2011-03-31 14:16:17,567 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory 2011-03-31 14:16:17,568 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - Optimize cache for minimal puts: disabled 2011-03-31 14:16:17,568 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - Structured second-level cache entries: enabled 2011-03-31 14:16:17,568 TRACE [SpringOsgiExtenderThread-46] SQLExceptionConverterFactory: - Using dialect defined converter 2011-03-31 14:16:17,570 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - Statistics: disabled 2011-03-31 14:16:17,570 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - Deleted entity synthetic identifier rollback: disabled 2011-03-31 14:16:17,571 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - Default entity-mode: pojo 2011-03-31 14:16:17,571 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - Named query checking : enabled 2011-03-31 14:16:17,589 INFO [SpringOsgiExtenderThread-46] SessionFactoryImpl: - building session factory 2011-03-31 14:16:17,590 DEBUG [SpringOsgiExtenderThread-46] SessionFactoryImpl: - Session factory constructed with filter configurations : {}
|