Red Hat

In Relation To Newsletter

In Relation To Newsletter

Welcome to the Hibernate community newsletter in which we share blog posts, forum, and StackOverflow questions that are especially relevant to our users.

Interviews

Don’t miss our Hibernate developer interviews with Arnold Gálovics and Jakub Kubryński.

If you want to share your story about Hibernate, let us know, and we can share it with our huge community of passionate developers.

Videos

I released a training video about the best way to log SQL statements with JDBC and Hibernate.

If you liked it, then don' forget to subscribe to my YouTube channel. I’ll release a new video every week, so stay tuned for more.

Articles

The pick of this Newsletter is this article by Randall Hyde from 2009 about the Fallacy of Premature Optimization. Way too often, performance is not considered from the very beginning when designing an enterprise application, and neglecting performance can have a serious impact when the application is launched into production.

Reading database Execution Plans is not a trivial thing to do. This article takes a different approach and tries to explain various algorithms employed by an Execution Plan using Java and C++ code examples.

While fetching entities is suitable when you plan to modify them, DTO projections are more convenient when for read-only transactions. Check out this article about the best way you can map a DTO projection using JPA and Hibernate.

If you’re using Spring Data JPA and want to use an automatic schema migration tool like Liquibase, then you should definitely read this step-by-step tutorial.

Whenever you find yourself self-joining two tables to correlate aggregate functions with the original table rows, you are better off using a Window Function. This article gives you two solutions to a given SQL problem: one with Window Functions and one without them. Not only that the Window Function query is more expressive, but it’s more efficient as well.

If you want to learn the difference between save, persist, merge, and saveOrUpdate, this article offers a very good introduction on this topic. While at it, there’s also a performance impact related to merge when doing batch processing. Luckily, the Hibernate-specific update method is there to help you tackle this issue.

Hibernate is extremely flexible. For instance, you can even use a Composite Identifier where one of the columns uses a @GeneratedValue directive. This is probably one of the few use cases where the JPA @IdClass construct actually makes sense.

Welcome to the Hibernate community newsletter in which we share blog posts, forum, and StackOverflow questions that are especially relevant to our users.

Interviews

Don’t miss our Hibernate developer interviews with Anghel Leonard.

If you want to share your story about Hibernate, let us know, and we can share it with our huge community of passionate developers.

Articles

Brandur has written a very detailed explanation about the implementation of MVCC (Multi-Version Concurrency Control) in PostgreSQL. For a beginner’s overview of what MVCC is and how it works, check out this article as well.

Hibernate Envers is probably the easiest way to set up an audit log if you are already using JPA and Hibernate. Check out this article to see the best audit strategy to use when choosing Envers as your audit log implementation.

Running out of database sequence values is a very serious issue. This article explains how this had happened on a production system, and offers both a quick fix and a solution for this problem.

Not only that it provides a solid implementation of the JPA specification, but Hibernate can be used for all sorts of tasks like for getting access to the binding between JPA entities and the underlying DB objects (e.g. table, column). Check out this article for more details on this topic.

This article explains how to persist a List of String objects as an @ElementCollection. Although simple, @ElementCollection, like any unidirectional association, is not very efficient. A bidirectional @OneToMany association where the String element becomes part of the Child entity is a much more efficient alternative.

Time to upgrade

Welcome to the Hibernate community newsletter in which we share blog posts, forum, and StackOverflow questions that are especially relevant to our users.

Articles

On Baeldung, you can find a very good article about JPA and Hibernate pagination. While JPA 2.2 defines support for Java 1.8 Stream operations. pagination is still the proffered way to controlling the amount of data being fetched.

Have you ever wondered how you can map a JPA many-to-many association with extra column? If you are interested in the best way to much a a relationship, then you should definitely read this article.

If you’re using a relational database, then you should be using a connection pool as well. Check out this article for an performance analysis of the most common Java connection pools. You will also need connection pool monitoring, and the FlexyPool open source framework allows you to do so.

Hibernate offers a dirty checking mechanism which automatically detects changes to managed entities. While the default mechanism is suitable for most use cases, you can even customize it as explained in this article.

If you ever wondered why you got the HHH000179: Narrowing proxy to class this operation breaks == warning message or wondered how to fix it, then you should read this article wrote by Marcin Chwedczuk.

Traditionally, storing EAV (Entity-Attribute-Value) data in a RDBMS has required various tricks to handle multiple value types. Now that most relational databases support JSON column types, you can use a custom Hibernate type to store your EAV data as a JsonNode object. Check out this article for a step-by-step tutorial that will show you how you can accomplish this task.

Joe Nelson wrote a great article about the difference between various SQL isolation levels with examples for various phenomena like read skew, write skew or lost updates.

Thorben Janssen gives you some tips about mapping the Many-To-One and One-To-Many associations. For more details, check out the best way to map a @OneToMany relationship with JPA and Hibernate article as well.

Questions and answers

Welcome to the Hibernate community newsletter in which we share blog posts, forum, and StackOverflow questions that are especially relevant to our users.

Articles

In this article, Arpit Jain writes about the differences between persist and merge in relation to JPA transaction boundaries. For more details about the persist and merge entity state transitions, check out this article as well.

For functional programming aficionados, TehDev wrote a very interesting article about refactoring towards a transaction monad.

If you’re using Payara Server, check out this article about how you can integrate it with Hibernate 5.

Baeldung published an article about the differences between persist, merge, update, as well as saveOrUpdate.

If you’re using Grails, Michael Scharhag shows you how you can make use of Hibernate filters.

JPA 2.2 has been released, but Hibernate has been supporting Java 1.8 Date and Time, Hibernate-specific @Repeatable annotations and, since 5.1, Java 1.8 streams are supported as well.

If you’re using MySQL, Thorben Janssen has written a list of tips to take into consideration when using Hibernate. If you are interested in more details, then check out the following articles as well:

Debezium is an open-source project developed by Red Hat which allows you to capture transaction events from RDBMS like MySQL, PostgreSQL or NoSQL solutions such as MongoDB and push them to Apache Kafka. For more details, check out this tutorial about using Debezium, MySQL and Kafka.

Welcome to the Hibernate community newsletter in which we share blog posts, forum, and StackOverflow questions that are especially relevant to our users.

Presentations

Check out the Virtual JUG presentation about High-Performance Java Persistence and Hibernate. If you are using a relational database, then you should definitely watch this session and learn how to run your enterprise application at warp speed.

Articles

The @Transactional annotation allows for a clear separation between business logic and transaction handling. However, just because you are using a very convenient abstraction, it does not mean you don’t have to understand how it works behind the scenes. Check out the "how does Spring @Transactional really work" article from jHades to know more on this topic.

If you’re using Payara Java EE Application Server and want to make it work with Hibernate 5, then you should definitely check out this tutorial.

I also wrote three articles that cover JPA 2.2 Date and Time types, Hibernate Array types, as well as CDC using Debezium.

Time to upgrade

Hibernate Validator 6.0.0.CR1 is out with Bean Validation 2.0.0.CR1 support.

Hibernate ORM 5.1.8 has been released, so, if you’re using the 5.1 branch, you should definitely give it a try.

Welcome to the Hibernate community newsletter in which we share blog posts, forum, and StackOverflow questions that are especially relevant to our users.

Presentations

Don’t miss the Virtual JUG presentation about High-Performance Java Persistence and Hibernate. If you are using a relational database, then you should definitely attend this session, and, the best thing about it, you can watch it in the comfort of your home.

Articles

The pick of this edition is this article by Arnold Galovics which reiterates the benefits of using projections when fetching data.

JPA inheritance is a very useful addition to the standard. However, sometimes entity inheritance is not very well understood or applied, so, in this series of articles, I tried to offer a different perspective to why we need entity inheritance in the first place, and what is the best way to do it:

Time to upgrade

Hibernate Search has managed to release three final versions:

  • 5.5.7.Final

  • 5.6.2.Final

  • 5.7.1.Final

as well as a 5.8.0.Beta3 release.

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.

Book discount

Until the 1st of June, High-Performance Java Persistence is 33% OFF. Considering the reader testimonials as well as Good Reads and Amazon reviews, it’s quite a deal!

Time to upgrade

  • Hibernate Validator 6.0.0 Beta1 and Beta2 were released.

  • Hibernate ORM 5.1.7 is out, so you should consider updating if you are running the 5.1 version.

Welcome to the Hibernate community newsletter in which we share blog posts, forum, and StackOverflow questions that are especially relevant to our users.

Articles

Mapping JPA relationships is a trivial thing to do. However, not all associations are equal in terms of performance. Check out this series of articles about the best way to map the:

If you’re using TomEE 7, you can easily switch to using Hibernate ORM as the JPA provider. Check out this article which shows you how you can do that, and how you can also speed up application server startup time.

Docker is extremely useful for running database containers that you need when doing integration testing. Check out this article about running IBM DB2 Express-C as a Docker container, and how to set up a JDBC connection to DB2.

Although collections like List and Set are more common when using JPA and Hibernate, you can easily use Maps as explained in this article.

Time to upgrade

Hibernate ORM 5.1.6 has been released, as well as Hibernate Search 5.8.0 Beta 2.

Welcome to the Hibernate community newsletter in which we share blog posts, forum, and StackOverflow questions that are especially relevant to our users.

Articles

Hibernate uses Proxy objects for lazy associations. If you want to understand how Porxy objects work and how you can unproxy them to the actual entities they represent, then you should definitely read this article.

Romain Manni-Bucau wrote a very interesting article which points out how you should be merging incoming and existing association collections when using Hibernate.

Getting access to the underlying database metadata is very easy with Hibernate 5. You just have to know how to make use of the Integrator SPI mechanism, as explained in this article.

Knowing how to implement equals and hashCode is of paramount importance when using JPA and Hibernate. Read this article by Steven Schwenke to find out business keys are very suitable for this task.

Bean Validation is a very convenient mechanism for validating entity state. Check out this article to find out how you can make sure that an integer value is within a bounded range.

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 Hibernate ResultTransformer is extremely useful to customize the way you fetch data from the database. Check out this article to learn more about this topic.

JPA and Hibernate use the first-level cache as a staging buffer for every read/write operation, and understanding its inner workings is very important if you want to use JPA effectively. For more details, you should definitely read this article.

Marco Behler offers 6 very practical video tutorials for Hibernate beginners.

Dealing with difficult software problems is easier than you might think. Check out this article for more details on how you can solve any software issue with the help of our wonderful software community.

If you wonder why you should choose Hibernate over plain JDBC, this article gives you 15 reasons why Hibernate is worth using.

This very short article offers a quick introduction to mapping a bidirectional one-to-many association. If you want to know what is the best way to map a one-to-many database relationship, then you should definitely read this article as well.

Database concurrency control is a very complex topic. PostgreSQL advisory locks are a very useful concurrency control API which you can use to implement multi-node coordination mechanisms. Check out this article for more details on this topic.

Time to upgrade

Hibernate ORM 5.2.10 has been released, as well as Hibernate Search 5.8.0.Beta1 which is now compatible with ElasticSearch 5.

back to top