Welcome to the Hibernate community newsletter in which we share blog posts, forum, and StackOverflow questions that are especially relevant to our users.
Articles
The pick of this edition is this article by Heap’s Engineering blog which demonstrates the benefits of using batch updates even for reducing database index overhead.
As previously explained, you can speed up integration tests considerably using a RAM disk or tmpfs. Mark Rotteveel tried this approach and looks like it works for Firebird as well.
Hibernate 5.2.10 comes with a very handy connection management optimization for RESOURCE_LOCAL transactions.
If you don’t use JTA and you disabled auto-commit at the connection pool level, then it’s worth setting the
hibernate.connection.provider_disables_autocommit
configuration property as well.
When using Oracle, the fastest way to access a database record is to use the ROWID
pseudocoolumn.
If using ROWID
is suitable for your application, then you can
annotate your entities with the @RowId
annotation
and Hibernate will use the ROWID
pseudocoolumn for UPDATE statements.
The best way to manage a database schema is to use incremental update scripts, and a tool like Flyway. Even in this case, you can still benefit from the hbm2ddl tool to validate the entity mappings. Check out how you can deal with schema mismatch exceptions, especially for non-trivial mappings.
You can use Hibernate statistics to log query execution time.
However, in reality, many enterprise application are better off using a JDBC DataSource
or Driver
Proxy
which, not only it allows you to log JDBC statements along with their parameters,
but you can even detect N+1 query issues automatically during testing.
Presentations
Jakub Kubryński has a very good presentation about JPA common pitfalls and how you should handle them effectively.
Questions and answers
-
How can we configure a Java Hibernate application using annotations?
-
Using Hibernate and TreeSet does not work the remove() and contains() methods
-
Why are bulk inserts with JPA much(!) slower than with pure JDBC insert?
-
Proper way to update a Set element in a JPA @OneToMany relationship?
-
Why is "hibernate.connection.autocommit = true" not recommended in Hibernate?
-
Can you have multiple transactions within one Hibernate Session?
-
HibernateException: Couldn’t obtain transaction-synchronized Session for current thread
-
Unexpected queries are being executed after connecting to MySQL while using Hibernate
-
How to avoid select statement during save in Spring Data JPA
-
Session.contains return false for object that load by OneToMany relation