Why, When and How to Use DTO Projections with JPA and Hibernate
|

Why, When and How to Use DTO Projections with JPA and Hibernate

DTOs are easy to use and the most efficient projection for read-only operations. So, whenever you don’t need to change the requested information, you should prefer a DTO projection. But what exactly is a DTO? How does such a projection work with Hibernate? And how can you use it in your queries? I will answer…

Hibernate Tip: Map a bidirectional one-to-one association with shared composite primary key
|

Hibernate Tip: Map a bidirectional one-to-one association with shared composite primary key

Hibernate Tips is a series of posts in which I describe a quick and easy solution for common Hibernate questions. If you have a question for a future Hibernate Tip, please post a comment below. Question: Today’s question was inspired by a question I answered on StackOverflow:How can I map a bidirectional one-to-one association that…

Implementing the Repository pattern with JPA and Hibernate
|

Implementing the Repository pattern with JPA and Hibernate

The repository pattern is extremely popular. In its modern interpretation, it abstracts the data store and enables your business logic to define read and write operations on a logical level. It does that by providing a set of methods to read, persist, update and remove an entity from the underlying data store. Old vs. modern…

Hibernate Tips: How to Handle NULL Values while Ordering Query Results in a CriteriaQuery
|

Hibernate Tips: How to Handle NULL Values while Ordering Query Results in a CriteriaQuery

Hibernate Tips is a series of posts in which I describe a quick and easy solution for common Hibernate questions. If you have a question for a future Hibernate Tip, please post a comment below. Question: You showed in a previous tip how to handle null values in a JPQL ORDER BY clause. Can I…