Cheat Sheet: New Features in JPA 2.1

JPA 2.1 introduced 12 new features, like StoreProcedureQueries, Entity Graphs and Attribute Converter, to make your work with the database easier and more efficient.
Download your free New Features in JPA 2.1 cheat sheet now, to get all the information you need to improve your database access.

This 5 page cheat sheet brings you:

- a short description and
- code snippets for each feature,
- links to more detailed articles.

Signup now and get your free New Features in JPA 2.1 cheat sheet and regular blog updates.

I respect your privacy and have ZERO TOLERANCE for spam!

Result Set Mapping: Constructor Result Mappings

This is the third part of my series about SQL result set mappings:
In the first post of this series, we had a look at some mapping definition between the query result and one entity. The mapping definitions got more complex in the second part, as we mapped the query result to multiple entities and handled additional columns. 
In this post, we will have a look at the Constructor Result Mappings introduced in JPA 2.1. This feature allows us to call the constructor of a value object with the result of the query, similar to the JPQL constructor expressions. This is often used, if we want to provide a specific view of our domain model to the client.

Java Weekly 17/15: Java stats, caching and JPA productivity

The Java world is evolving at a rapid pace and it can be challenging to keep track of it. Fortunately lots of great resources are created every week, explaining new features or looking at existing stuff from a different angle.

I am using the Java Weekly series to collect the most interesting links I found during the last week and present them to you all in one place. I hope you find it useful and that it makes it easier for you to keep up-to-date. If you like to suggest a resource or something I can improve on, please leave me a comment.



Result Set Mapping: Complex Mappings

This is the second part of my SQL result set mappings series. We had a look at some basic result type mappings in the first post Result Set Mapping: The Basics. In this one, we will define more complex mappings that can map a query result to multiple entities and handle additional columns that cannot be mapped to a specific entity.
  • Result Set Mapping: The Basics
  • Result Set Mapping: Complex Mappings
  • Result Set Mapping: Constructor Result Mappings (coming soon)
  • Result Set Mapping: Hibernate specific features (coming soon)

Java Weekly 16/15: Microservice design patterns, scopes for JBatch, Java 8 concurrency, IoT with Java ME 8 and more

The Java world is evolving at a rapid pace and it can be challenging to keep track of it. Fortunately lots of great resources are created every week, explaining new features or looking at existing stuff from a different angle.

I am using the Java Weekly series to collect the most interesting links I found during the last week and present them to you all in one place. I hope you find it useful and that it makes it easier for you to keep up-to-date. If you like to suggest a resource or something I can improve on, please leave me a comment.


Result Set Mapping: The Basics

Quite often JPQL is not powerful enough to perform the queries we need in real world projects. In general, this is not an issue because JPA is designed as a leaky abstraction and we can use the full potential of SQL by using native queries or calling stored procedures.
The only downside is, that these queries return a List of Object[] instead of the mapped entities and value objects we are used to work with. Each Object[] contains one record returned by the database. We then need to iterate through the array, cast each Object to its specific type and map them to our domain model. This creates lots of repetitive code and type casts as you can see in the following example.


It would be more comfortable, if we could tell the EntityManager to map the result of the query into entities or value objects as it is the case for JPQL statements. The good news is, JPA provides this functionality. It is called SQL result set mapping and we will have a detailed look at it during this series:
  • Result Set Mapping: The Basics
  • Result Set Mapping: Complex Mappings
  • Result Set Mapping: Constructor Result Mappings (coming soon)
  • Result Set Mapping: Hibernate specific features (coming soon)

Java Weekly 15/15: GC tuning, HTTP2, good Javadoc, MVC 1.0 early draft

The Java world is evolving at a rapid pace and it can be challenging to keep track of it. Fortunately lots of great resources are created every week, explaining new features or looking at existing stuff from a different angle.

I am using the Java Weekly series to collect the most interesting links I found during the last week and present them to you all in one place. I hope you find it useful and that it makes it easier for you to keep up-to-date. If you like to suggest a resource or something I can improve on, please leave me a comment.



Java Weekly: April Fools Edition

Normally, I am using the Java Weekly series to collect the most interesting Java related links. But today I prepared a special April Fool Edition for you. I hope you enjoy it.