我已经配置了hibernate批处理配置
spring.jpa.properties.hibernate.jdbc.batch_size = 20
spring.jpa.properties.hibernate.order_inserts = true
spring.jpa.properties.hibernate.order_updates = true
spring.jpa.properties.hibernate.generate_statistics=true
字符串
当调用saveAll()时,它生成与列表包含的实体一样多的语句。
指标
5702800 nanoseconds spent acquiring 1 JDBC connections;
0 nanoseconds spent releasing 0 JDBC connections;
19521800 nanoseconds spent preparing 111 JDBC statements;
462709900 nanoseconds spent executing 109 JDBC statements;
85106100 nanoseconds spent executing 7 JDBC batches;
0 nanoseconds spent performing 0 L2C puts;
0 nanoseconds spent performing 0 L2C hits;
0 nanoseconds spent performing 0 L2C misses;
290977000 nanoseconds spent executing 1 flushes (flushing a total of 110 entities and 109 collections);
0 nanoseconds spent executing 0 partial-flushes (flushing a total of 0 entities and 0 collections)
型
编码
List<TaskImage> taskImages = TASK_ID_TO_IMAGE_MAPPER.apply(entityIds, pollInfo.getLastPollDate());
return taskImageRepository.saveAll(taskImages);
型
hibernateshow-sql是启用的,在consol中,它会逐个显示所有语句。
注意:Map也会插入主键,不会自动生成。
我知道我可以使用Spring Data JDBC来完成它,但我想使用Spring Data JPA来克服它。
1条答案
按热度按时间o2gm4chl1#
答案是它实际上是正确工作的。这些查询是SELECT查询,因为数据已经存在于DB中,所以调用hibernate合并操作并运行脏检查机制。