question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

hibernate-orm is missing some important Hibernate batch configuration options

See original GitHub issue

Description

See https://quarkus.io/guides/hibernate-orm for current list and https://vladmihalcea.com/how-to-batch-insert-and-update-statements-with-hibernate/ for additional needed options, e.g.

  • hibernate.order_inserts
  • hibernate.order_updates
  • hibernate.jdbc.batch_versioned_data

Is it planned to add them?

Workaround

Using persistence.xml

Implementation ideas

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

4reactions
kay-horstcommented, Feb 25, 2022

As to hibernate.order_inserts: I have optimized bulk inserts by a factor of about 50 by using Hibernate batching in the case of entities without relations. This optimization is very important for the application.

However, for an entity type using @OneToMany, batching is not applied due to the entity types’ not being sorted, so that single INSERTs are being generated.

It would be good to be able to stick with application.yaml properties instead of having to revert to a persistence.xml.

My suggestion for a “salomonic” solution: Instead of adding this property, which seems to have problems in some cases, to the quarkus.hibernate-orm.* - path, introduce quarkus.jpa.properties.* (analogous to SpringData), where one can set native JPA provider properties, which in the case of Hibernate will translate:

quarkus.jpa.properties.foo.baz -> hibernate.foo.baz

Thus, hibernate-orm can stick to a limited set of “opinionated” properties based on the module developers’ reasoning, but the application developer has the liberty to apply arbitrary properties at their own risk. If it is made clear in the documentation, that using this puts the application developers at their own risk, it should not be too much of a hassle.

1reaction
Sannecommented, Aug 2, 2021

Right, and same for the others.

FWIW:

  • AvailableSettings.ORDER_UPDATES is always enabled in Quarkus, as we believe it’s the better option and has no known drawbacks.
  • ORDER_INSERTS is meant to be enabled in a similar way in the future, it’s not today as there are some open issues related to it.

Regarding BATCH_VERSIONED_DATA, we’re not setting it today but I guess we could take this in consideration; I’d need to better understand what implications this would have on designing applications making use of optimistic lockinng.

In general, I prefer to not expose many of these but rather make sure we automatically set the best strategies; this might also lead to removing of some such properties from ORM down the road, and allow us to better test all permutations of these options.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hibernate ORM 5.6.14.Final User Guide - Red Hat on GitHub
There is yet another important runtime impact of choosing IDENTITY generation: Hibernate will not be able to batch INSERT statements for the entities...
Read more >
Using Hibernate ORM and JPA - Quarkus
When using Hibernate ORM in Quarkus, you don't need to have a persistence.xml resource to configure it. Using such a classic configuration file...
Read more >
GORM for Hibernate - Grails
And the following are common configuration options for Hibernate: ... Hibernate batches up SQL statements and executes them as late as possible, ...
Read more >
Logging Guide for Hibernate 4, 5 & 6 - Use the right config for ...
Some logging features, like the slow query log, aren't available in older Hibernate versions, and Hibernate 6 changed the names of a few...
Read more >
Home of Quarkus Cheat-Sheet - GitHub Pages
You can define the main CLI method to start Quarkus. ... You can define for each Test class a different configuration options. ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found