|

Implement your primary key as a Record using an IdClass

There are various reasons to implement your own primary key representation. Your primary key may consist of multiple attributes. Or you’re following domain-driven design principles and want to use a custom type to add semantic meaning to it. Implementing a record and mapping it as an IdClass seems evident in these situations. A record is efficient, easy to implement, immutable…

How to generate DAOs and queries with Hibernate
|

How to generate DAOs and queries with Hibernate

Executing a query with Hibernate requires several lines of repetitive boilerplate code, and many developers have complained about that for years. You have to instantiate a Query object and set all bind parameter values before you can finally execute the query. Since version 6.3.1, Hibernate has solved this with an improved metamodel generator that provides…

TimezoneStorageType – Hibernate’s improved timezone mapping
|

TimezoneStorageType – Hibernate’s improved timezone mapping

Working with timestamps with timezone information has always been a struggle. Since Java 8 introduced the Date and Time API, OffsetDateTime and ZonedDateTime have become the most obvious and commonly used types to model a timestamp with timezone information. And you might expect that choosing one of them should be the only thing you need…

8 things you need to know when migrating to Hibernate 6.x
|

8 things you need to know when migrating to Hibernate 6.x

Hibernate 6 has been released for a while, and the latest Spring Data JPA version includes it as a dependency. So, it’s no surprise that more and more developers want to migrate their applications to the latest Hibernate version. As you’re reading this article, you’re probably one of them. And you might ask yourself what…