Hibernate’s ResultTransformer in Hibernate 4, 5 & 6
| | |

Hibernate’s ResultTransformer in Hibernate 4, 5 & 6

Hibernate implements JPA’s standardized constructor expressions and @SqlResultSetMappings to map the results of your queries. And it also supports proprietary ResultTransformers. They provide a powerful and flexible way to map the result of your JPQL, Criteria, and native SQL query to a specific object structure. This can be entity or DTO objects, java.util.List or java.util.Map…

How to configure List semantics in Hibernate 6
|

How to configure List semantics in Hibernate 6

Based on its javadoc, a java.util.List is supposed to represent an ordered collection of values. But that’s not necessarily the case if you use it as the type of a to-many association or an ElementCollection. As I explained before, Hibernate can handle a java.util.List as a Bag or a List. Only the List mapping persists the order…

MutationQuery and SelectionQuery in Hibernate 6
|

MutationQuery and SelectionQuery in Hibernate 6

One of the smaller changes in Hibernate 6 that can easily get overlooked, which Steve Ebersole presented in a recent Expert Session in the Persistence Hub, is the introduction of the MutationQuery and SelectionQuery interfaces. It allows the separation between queries that change data and the ones that select it from the database. Older Hibernate…

Native Queries – How to call native SQL queries with JPA & Hibernate
| | |

Native Queries – How to call native SQL queries with JPA & Hibernate

The Java Persistence Query Language (JPQL) is the most common way to query data from a database with JPA. It enables you to reuse your mapping definitions and is easier to use than SQL. But it supports only a small subset of the SQL standard, and it also provides no support for database-specific features. So…

Hibernate 6 EmbeddableInstantiator – Instantiate embeddables your way
| |

Hibernate 6 EmbeddableInstantiator – Instantiate embeddables your way

Embeddables are simple Java objects. They provide an easy way to define and group a set of attributes that become part of your entity. Developers often use them to create reusable mapping information and handle them using the same piece of business code. Unfortunately, the JPA specification and Hibernate until version 6.0.0, required your embeddable…