How to use PostgreSQL’s JSONB data type with Hibernate
| |

How to use PostgreSQL’s JSONB data type with Hibernate

Most databases offer many proprietary features besides the known SQL standard. One example is PostgreSQL’s JSONB data type which allows you to store JSON documents efficiently in a database column. You could, of course, store the JSON document in a text column. That column type is part of the SQL standard. Hibernate and all other…

How to generate UUIDs as primary keys with Hibernate
| |

How to generate UUIDs as primary keys with Hibernate

Most developers prefer numerical primary keys because they are efficient to use and easy to generate. But that doesn’t mean that a primary key has to be a number. UUIDs, for example, have gained some popularity over recent years. The main advantage of a UUID is its (practical) global uniqueness which provides a huge advantage…

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…