Why you should use the Hibernate ResultTransformer to customize result set mappings

Introduction JPA queries allow you to fetch either entities or DTO projections. However, sometimes you want a combined result set as illustrated in this Hibernate forum question. Domain Model Assuming you have the following entities: The relationship between the two entities is not materialized in a @ManyToOne association. However, both entities share a locale attribute which we can use to form a join between the two. Returning an entity in a DTO projection As I explained before, DTO projections are suitable for read-only transactions and fetching data that is not meant to … Continue reading Why you should use the Hibernate ResultTransformer to customize result set mappings