How to map camelCase properties to snake_case column names with Hibernate

Introduction In this article, you are going to learn how to map cameCase entity properties (e.g. phoneNumber) to snake_case column names (e.g. phone_number) using a Hibernate naming strategy. While you could achieve the same goal with the name attribute of JPA @Column annotation, it’s much more convenient to use a custom Hibernate strategy to apply this naming convention consistently.

How to fix the Hibernate “No Dialect mapping for JDBC type” issue

Introduction Recently, stumbled on this question on the Hibernate forum, and since I’ve been seeing it before on StackOverflow and bumped into it myself while working with JPA and Hibernate, I decided to turn the answer into an article. Therefore, in this article, you are going to find out how you can fix the “No Dialect mapping for JDBC type” Hibernate issue.

How to map a JPA entity to a View or SQL query using Hibernate

Introduction In this article, you are going to learn how to map a JPA entity to the ResultSet of a SQL query using the @Subselect Hibernate-specific annotation.

How to emulate @CreatedBy and @LastModifiedBy from Spring Data using the @GeneratorType Hibernate annotation

Introduction Hibernate comes with many additions to the standard JPA specification. One such example is the @GeneratorType annotation which allows you to customize the way a given entity property value is automatically generated. If you’re using Spring Data, you can simply use the @CreatedBy and @LastModifiedBy annotations and the annotated entity properties are going to be populated with the currently logged user. If you’re not using Spring Data, then you can easily emulate the same behavior using the Hibernate-specific @GeneratorType annotation and the ValueGenerator callback mechanism.

The best way to map a @NaturalId business key with JPA and Hibernate

Introduction As I explained in this free chapter of my book, Hibernate offers many benefits over standard JPA. One such example is the @NaturalId mapping. In this article, you are going to see what is the best way to map a natural business key when using Hibernate.