JPA Hibernate:帮助经典批处理插入值 (...),(...),(...)
我已经阅读了论坛/搜索了高低,但这不会像我预期的那样批量处理。 简而言之,我希望插入时间序列值 (...)、(...)、(...) 将插入批量插入到一个语句中。
Postgres 9. 休眠3.4.0。 JPA 1.99
该实体与其他实体/集合没有关系,它完全由其本身进行版本控制,并使用 GenerationType.SEQUENCE
以下是互联网上所说的应该激活此功能的内容。
在 Java 中,在我的 @Transactional 中,我仅对该类型的实体调用 .merge。我也尝试过调用 persist,并禁用版本控制……没有运气…… 我在日志中注意到这一点: AbstractBatcher: - 没有要执行的批处理语句
有帮助吗?
这是一些相关的调试跟踪...为了简单起见,减少了...
2011-03-31 14:20:37,414 TRACE [pool-2-thread-3] AbstractSaveEventListener: - 瞬态实例:com.xxx.TimeSeriesEntity 2011-03-31 14:20:37,414 TRACE [pool-2-thread-3] DefaultPersistEventListener:-保存瞬态实例 2011-03-31 14:20:37,414 调试 [pool-2-thread-3] AbstractSaveEventListener: - 生成标识符: 188032722, 使用策略: org.hibernate.id.SequenceHiLoGenerator 2011-03-31 14:20:37,414 跟踪 [pool-2-thread-3] AbstractSaveEventListener: - 保存 [com.xxx.TimeSeriesEntity#188032722] 2011-03-31 14:20:37,414 TRACE [pool-2-thread-3] 版本控制: - 使用初始版本:0 2011-03-31 14:20:37,414 TRACE [pool-2-thread-3] AbstractFlushingEventListener:-刷新会话 2011-03-31 14:20:37,414 调试 [pool-2-thread-3] AbstractFlushingEventListener:- 处理刷新时间级联 //snip
2011-03-31 14:20:37,414 TRACE [pool-2-thread-3] Cascade: - 处理级联 ACTION_PERSIST_ON_FLUSH for: com.xxx.TimeSeriesEntity 2011-03-31 14:20:37,414 TRACE [pool-2-thread-3] Cascade: - 完成处理级联 ACTION_PERSIST_ON_FLUSH for: com.xxx.TimeSeriesEntity //snip
2011-03-31 14:20:37,415 DEBUG [pool-2-thread-3] AbstractFlushingEventListener: - 脏检查集合 2011-03-31 14:20:37,415 TRACE [pool-2-thread-3] AbstractFlushingEventListener: - 刷新实体并处理引用的集合 2011-03-31 14:20:37,415 TRACE [pool-2-thread-3] AbstractEntityPersister:- com.xxx.TimeSeriesEntity.highestValidDataStartTime 脏 2011-03-31 14:20:37,415 TRACE [pool-2-thread-3] AbstractEntityPersister:- com.xxx.TimeSeriesEntity.seriesEndTime 脏 2011-03-31 14:20:37,415 TRACE [pool-2-thread-3] AbstractEntityPersister:- com.xxx.TimeSeriesEntity.seriesStartTime 脏 2011-03-31 14:20:37,415 TRACE [pool-2-thread-3] DefaultFlushEntityEventListener: - 更新实体: [com.xxx.TimeSeriesEntity#188032673] 2011-03-31 14:20:37,415 TRACE [pool-2-thread-3] 版本控制:- 递增:0 到 1 //snip
2011-03-31 14:20:37,418 TRACE [pool-2-thread-3] AbstractFlushingEventListener: - 处理未引用的集合 2011-03-31 14:20:37,418 TRACE [pool-2-thread-3] AbstractFlushingEventListener: - 调度集合删除/(重新)创建/更新 2011-03-31 14:20:37,418 调试 [pool-2-thread-3] AbstractFlushingEventListener: - 刷新: 50 次插入、50 次更新、0 次删除至 50 个对象 2011-03-31 14:20:37,418 调试 [pool-2-thread-3] AbstractFlushingEventListener: - 刷新: 0 (重新) 创建、0 更新、0 删除到 0 个集合 //snip
2011-03-31 14:20:37,419 TRACE [pool-2-thread-3] AbstractFlushingEventListener: - 执行刷新 2011-03-31 14:20:37,419 TRACE [pool-2-thread-3] ConnectionManager:-注册刷新开始 2011-03-31 14:20:37,419 TRACE [pool-2-thread-3] AbstractEntityPersister: - 插入实体: [com.xxx.TimeSeriesEntity#188032673] 2011-03-31 14:20:37,419 TRACE [pool-2-thread-3] AbstractEntityPersister:-版本:0 2011-03-31 14:20:37,419 DEBUG [pool-2-thread-3] AbstractBatcher:-即将打开PreparedStatement(打开PreparedStatements:0,全局:1) 2011-03-31 14:20:37,419 调试 [pool-2-thread-3] SQL: - 插入时间序列(calc_type、channel_id、counts、data_value、粒度、highest_valid_data_time、max_value、min_value、series_end_time、series_start_time、version、series_id ) 值 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) 2011-03-31 14:20:37,419 TRACE [pool-2-thread-3] AbstractBatcher:-准备语句 2011-03-31 14:20:37,419 TRACE [pool-2-thread-3] AbstractEntityPersister: - 脱水实体: [com.xxx.TimeSeriesEntity#188032673] 2011-03-31 14:20:37,419 TRACE [pool-2-thread-3] LongType: - 将“52283”绑定到参数:2 2011-03-31 14:20:37,419 TRACE [pool-2-thread-3] IntegerType: - 将“0”绑定到参数:11 2011-03-31 14:20:37,419 TRACE [pool-2-thread-3] LongType: - 将“188032673”绑定到参数:12 2011-03-31 14:20:37,419 TRACE [pool-2-thread-3] AbstractEntityPersister: - 插入实体: [com.xxx.TimeSeriesEntity#188032674] 2011-03-31 14:20:37,420 TRACE [pool-2-thread-3] AbstractEntityPersister:-版本:0 2011-03-31 14:20:37,420 调试 [pool-2-thread-3] AbstractBatcher:- 重用准备好的语句 2011-03-31 14:20:37,420 调试 [pool-2-thread-3] SQL: - 插入时间序列(calc_type、channel_id、counts、data_value、粒度、highest_valid_data_time、max_value、min_value、series_end_time、series_start_time、version、series_id ) 值 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) //snip
2011-03-31 14:20:37,478 DEBUG [pool-2-thread-3] AbstractBatcher: - 执行批量大小: 50 2011-03-31 14:20:37,506 DEBUG [pool-2-thread-3] AbstractBatcher:-没有要执行的批处理语句 2011-03-31 14:20:37,506 DEBUG [pool-2-thread-3] AbstractBatcher:-即将关闭PreparedStatement(打开PreparedStatements:1,全局:2) 2011-03-31 14:20:37,506 TRACE [pool-2-thread-3] AbstractBatcher:-结束语 2011-03-31 14:20:37,506 TRACE [pool-2-thread-3] ConnectionManager:-注册刷新结束 2011-03-31 14:20:37,506 TRACE [pool-2-thread-3] AbstractFlushingEventListener:-刷新后 2011-03-31 14:20:37,507 TRACE [pool-2-thread-3] VersionValue: - 版本未保存值策略未定义 2011-03-31 14:20:37,507 跟踪 [pool-2-thread-3] IdentifierValue: - id 未保存值: 0 2011-03-31 14:20:37,507 TRACE [pool-2-thread-3] AbstractSaveEventListener: - 瞬态实例:com.xxx.TimeSeriesEntity 2011-03-31 14:20:37,507 TRACE [pool-2-thread-3] DefaultPersistEventListener:-保存瞬态实例 2011-03-31 14:20:37,507 DEBUG [pool-2-thread-3] AbstractSaveEventListener:-生成标识符:188032723,使用策略:org.hibernate.id.SequenceHiLoGenerator 2011-03-31 14:20:37,507 跟踪 [pool-2-thread-3] AbstractSaveEventListener: - 保存 [com.xxx.TimeSeriesEntity#188032723] 2011-03-31 14:20:37,507 TRACE [pool-2-thread-3] 版本控制: - 使用初始版本:0 2011-03-31 14:20:37,507 TRACE [pool-2-thread-3] VersionValue: - 版本未保存值策略未定义 2011-03-31 14:20:37,507 跟踪 [pool-2-thread-3] IdentifierValue: - id 未保存值: 0 2011-03-31 14:20:37,507 TRACE [pool-2-thread-3] AbstractSaveEventListener: - 瞬态实例:com.xxx.TimeSeriesEntity 2011-03-31 14:20:37,507 TRACE [pool-2-thread-3] DefaultPersistEventListener:-保存瞬态实例 2011-03-31 14:20:37,507 DEBUG [pool-2-thread-3] AbstractSaveEventListener:-生成标识符:188032724,使用策略:org.hibernate.id.SequenceHiLoGenerator 2011-03-31 14:20:37,507 跟踪 [pool-2-thread-3] AbstractSaveEventListener: - 保存 [com.xxx.TimeSeriesEntity#188032724] 2011-03-31 14:20:37,507 TRACE [pool-2-thread-3] 版本控制: - 使用初始版本:0 2011-03-31 14:20:37,507 TRACE [pool-2-thread-3] VersionValue: - 版本未保存值策略未定义 2011-03-31 14:20:37,507 TRACE [pool-2-thread-3] IdentifierValue: - id unsaved-value: 0
这是会话工厂 init:
2011-03-31 14:16:17,521 INFO [SpringOsgiExtenderThread- 46] InjectedDataSourceConnectionProvider:-使用提供的数据源 2011-03-31 14:16:17,535 信息 [SpringOsgiExtenderThread-46] SettingsFactory: - RDBMS: PostgreSQL, 版本: 9.0.2 2011-03-31 14:16:17,535 INFO [SpringOsgiExtenderThread-46] SettingsFactory:- JDBC驱动程序:PostgreSQL本机驱动程序,版本:PostgreSQL 9.0 JDBC4(内部版本801) 2011-03-31 14:16:17,560 信息 [SpringOsgiExtenderThread-46] 方言: - 使用方言:org.hibernate.dialect.PostgreSQLDialect 2011-03-31 14:16:17,564 INFO [SpringOsgiExtenderThread-46] TransactionFactoryFactory: - 事务策略:org.hibernate.transaction.JDBCTransactionFactory 2011-03-31 14:16:17,564 INFO [SpringOsgiExtenderThread-46] TransactionManagerLookupFactory: - 未配置 TransactionManagerLookup (在 JTA 环境中,不建议使用读写或事务二级缓存) 2011-03-31 14:16:17,565 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - beforeCompletion()期间自动刷新:禁用 2011-03-31 14:16:17,565 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - 事务结束时自动会话关闭:已禁用 2011-03-31 14:16:17,565 信息 [SpringOsgiExtenderThread-46] SettingsFactory:- JDBC 批量大小:50 2011-03-31 14:16:17,565 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - 版本化数据的 JDBC 批量更新:已启用 2011-03-31 14:16:17,565 INFO [SpringOsgiExtenderThread-46] SettingsFactory:-可滚动结果集:启用 2011-03-31 14:16:17,565 调试 [SpringOsgiExtenderThread-46] SettingsFactory:- 换行结果集:禁用 2011-03-31 14:16:17,565 信息 [SpringOsgiExtenderThread-46] SettingsFactory:- JDBC3 getGenerateKeys():启用 2011-03-31 14:16:17,565 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - 连接释放模式:自动 2011-03-31 14:16:17,566 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - 默认批量获取大小:1 2011-03-31 14:16:17,566 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - 生成带注释的 SQL:已禁用 2011-03-31 14:16:17,566 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - 按主键排序 SQL 更新:启用 2011-03-31 14:16:17,566 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - 为批处理排序 SQL 插入:启用 2011-03-31 14:16:17,566 信息 [SpringOsgiExtenderThread-46] SettingsFactory: - 查询翻译器: org.hibernate.hql.ast.ASTQueryTranslatorFactory 2011-03-31 14:16:17,567 信息 [SpringOsgiExtenderThread-46] ASTQueryTranslatorFactory:- 使用 ASTQueryTranslatorFactory 2011-03-31 14:16:17,567 INFO [SpringOsgiExtenderThread-46] SettingsFactory:-查询语言替换:{} 2011-03-31 14:16:17,567 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - JPA-QL 严格合规性:启用 2011-03-31 14:16:17,567 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - 二级缓存: 禁用 2011-03-31 14:16:17,567 信息 [SpringOsgiExtenderThread-46] SettingsFactory:- 查询缓存:已禁用 2011-03-31 14:16:17,567 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - 缓存区域工厂:org.hibernate.cache.impl.NoCachingRegionFactory 2011-03-31 14:16:17,568 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - 优化缓存以实现最少的放置:已禁用 2011-03-31 14:16:17,568 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - 结构化二级缓存条目:启用 2011-03-31 14:16:17,568 TRACE [SpringOsgiExtenderThread-46] SQLExceptionConverterFactory: - 使用方言定义的转换器 2011-03-31 14:16:17,570 信息 [SpringOsgiExtenderThread-46] SettingsFactory: - 统计信息: 已禁用 2011-03-31 14:16:17,570 INFO [SpringOsgiExtenderThread-46] SettingsFactory:-删除的实体合成标识符回滚:禁用 2011-03-31 14:16:17,571 INFO [SpringOsgiExtenderThread-46] SettingsFactory:-默认实体模式:pojo 2011-03-31 14:16:17,571 INFO [SpringOsgiExtenderThread-46] SettingsFactory: - 命名查询检查:启用 2011-03-31 14:16:17,589 INFO [SpringOsgiExtenderThread-46] SessionFactoryImpl:-构建会话工厂 2011-03-31 14:16:17,590 调试 [SpringOsgiExtenderThread-46] SessionFactoryImpl: - 使用过滤器配置构造的会话工厂:{}
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 timeseries 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.
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.highestValidDataStartTime is dirty
2011-03-31 14:20:37,415 TRACE [pool-2-thread-3] AbstractEntityPersister: - com.xxx.TimeSeriesEntity.seriesEndTime is dirty
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 : {}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Hibernate 使用批量插入。这并不意味着使用单个语句来插入许多实体。这意味着它使用
Statement.addBatch()
和Statement.executeBatch()
内部。这有效地减少了数据库的访问次数(阅读链接的 javadoc 以获取更详细的解释),并且我非常怀疑它的性能低于(或明显低于)单个插入语句。在优化之前,确保存在性能问题,并确定性能问题来自何处。
Hibernate uses batch inserts. This does not mean that a single statement is used to insert many entities. It means it uses
Statement.addBatch()
andStatement.executeBatch()
internally. This effectively reduces the number of roadtrips to the database (read the linked javadoc for more detailed explanations), and I very much doubt it's less (or significantly less) performant than a single insert statement.Before optimizing, make sure there is a performance problem, and make sure to spot where the performance problem comes from.