Common Hibernate Exceptions Every Developer Must Know
|

Common Hibernate Exceptions Every Developer Must Know

Every framework has a set of exceptions that indicate common error scenarios. Understanding them will help you turn a task that could drag along for days into a quickly-implemented feature. When working with Hibernate, they tell you about issues with your database queries, mapping mistakes, and problems during write operations. In this article, I want…

How to use Ehcache as Hibernate’s 2nd Level Cache

How to use Ehcache as Hibernate’s 2nd Level Cache

Using JPA’s and Hibernate’s 2nd level cache can improve the performance of your persistence layer. It acts as a session-independent entity store. Hibernate uses it whenever you call the find method on your EntityManager or traverse an association to fetch a cached entity. Instead of executing a database query, Hibernate gets the entity object from…

Java Text Blocks – Using Multiline Strings with Hibernate & JPA
|

Java Text Blocks – Using Multiline Strings with Hibernate & JPA

JPA and Hibernate require you to write lots of Strings. You use them to create ad-hoc and named queries with JPQL, to define native SQL queries and to specify the fetching behavior in an EntityGraph. Until Java 13, the lack of multiline Strings in Java made all of these tasks either annoying to implement or…