14 High-Performance Java Persistence Tips

Introduction A high-performance data access layer requires a lot of knowledge about database internals, JDBC, JPA, Hibernate, and this post summarizes some of the most important techniques you can use to optimize your enterprise application. 1. SQL statement logging If you’re using a framework that generates statements on your behalf, you should always validate each statement effectiveness and efficiency. A testing-time assertion mechanism is even better because you can catch N+1 query problems even before you commit your code. 2. Connection management Database connections are expensive, therefore you should always use a… Read More

How to map JSON objects using generic Hibernate Types

Introduction Since not all relational database systems support JSON types, Hibernate does not come with a built-in JSON Type mapper. Traditionally, all custom types have been supplied via a UserType implementation. However, a UserType is not very developer friendly so, in this post, I’m going to show how you can do a better job using AbstractSingleColumnStandardBasicType instead.

High-Performance Java Persistence – Part Two

Another milestone has been reached The second part of High-Performance Java Persistence book is out. It’s been almost a year since I started writing this book, and seven months since I published the first part.

How to implement a custom String-based sequence identifier generator with Hibernate

Introduction One of my blog readers bumped into the assigned generator with a sequence or an identity column post and wondered if it was possible to generate String-based identifiers instead. I accepted the challenge and answered his question on StackOverflow. However, this post is going to explain this topic in greater detail, so there we go.

How to implement equals and hashCode using the JPA entity identifier (Primary Key)

Introduction As previously explained, using the JPA entity business key for equals and hashCode is always best choice. However, not all entities feature a unique business key, so we need to use another database column that is also unique, like the primary key. But using the entity identifier for equality is very challenging, and this post is going to show you how you can use it without issues.

New Video Course