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…

Using Window Functions with Hibernate 5 & 6
|

Using Window Functions with Hibernate 5 & 6

SQL is an incredibly powerful query language. It provides sheer endless possibilities to extract and transform information. One example of that is a window function. It enables you to perform operations on subsets of the table rows available in your query. The PostgreSQL documentation explains window functions as: A window function performs a calculation across a set…

Spring Data JPA – How to create a custom base repository

Spring Data JPA – How to create a custom base repository

Most developers create their own repositories by adding their queries to one of Spring Data JPA’s standard base repositories, like the JpaRepository or the CrudRepository. These repositories give you a set of standard operations, e.g., to read and write entity objects. It often seems like the obvious choice to define your own repositories based on one of these…

The difference between Spring Data JPA’s findById, getOne, getById, and findOne methods

The difference between Spring Data JPA’s findById, getOne, getById, and findOne methods

Spring Data’s JpaRepository provides a huge set of methods that simplify the implementation of your database operations. You can use them to persist, remove, and read an entity object. Choosing the right method for your use case is one of the few problems these interfaces create. And that’s sometimes not as easy as you might expect. One…