JPA Pitfalls – a Series of Serious JPA Obstacles

Most of our Java-based web-applications store their data in a relational database such as Oracle, PostgreSQL, MySQL, MariaDB or MS SQLServer. The standard way to access and modify the data is using an object-relational mapping as specified by the Java Persistence API (JPA). Over the years JPA has become a mature specification and there are a couple of JPA implementations with strong support such as Hibernate, EclipseLink, OpenJPA and DataNucleus. However, day-to-day project experience demonstrates there are number of pitfalls you might run into when using JPA.

pitfall

To avoid stumbling into the same pitfall again and again, we collected them with their solutions and presented these pairs of problems and solutions. This is a start of a series of blog articles each describing a pitfall and a way to circumvent it.

For every pitfall, there is a description and an executable code example. You find all the code examples here: https://github.com/akquinet/jpapitfalls.git.

We have four categories of pitfalls. Each new pitfall will be added as a new list item:

  1. Object-relational mapping and relationships
    1. Serialized Collection
    2. List or Set Relationship
    3. Cascade Persist
    4. Relationship Owner
  2. Object-relational mapping and inheritance
    1. Object-Relational Mapping and Inheritance
  3. JPQL queries such as unexpected query results
    1. Query Result with Duplicates
    2. Null Parameter
  4. Runtime issues such as lost updates or performance issues

We first start with a pitfall called: “Serialized Collection

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.