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…

How to persist additional attributes for an association with JPA and Hibernate
|

How to persist additional attributes for an association with JPA and Hibernate

JPA and Hibernate allow you to define associations between entities with just a few annotations, and you don’t have to care about the underlying table model in the database. Even join tables for many-to-many associations are hidden behind a @JoinTable annotation, and you don’t need to model the additional table as an entity. That changes…

How to map composite column types with Hibernate
|

How to map composite column types with Hibernate

When most developers design their table and entity models, they create tables that only use basic column types and map these to basic entity attributes. Even though these are the most commonly used types, they are not the only ones supported by modern relational databases and Hibernate. You can also use composite, JSON, and XML…

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…