JPA 2.1 Tutorial

This section is discussing about JPA 2.1 and provides many tutorials along with many example codes on JPA 21.1. In JEE 7 application it is mandatory to use the JPA 2.1 for creating persistence layer code.

JPA 2.1 Tutorial

Learn the new features of JPA 2.1 and understand how to use the new features of JPA 2.1

The Java Persistence API Version 2.1 or simply JPA 2.1 is part of JEE 7 specification which provides and object/relational mapping facility for using the data from relational database in Java based applications. The JPA allows the developers to persist the Java Entity class with the help of Java persistence API. You can use the JPA API to query the data from database.

The JPA is Java based solutions for mapping the persistence with the relational databases. The JPA uses the object/relational mapping approach which very useful in bridging the gap between object-oriented model and the relational databases. Now JPA can be used outside the JEE 7 container and can be used even in Java SE applications.

The JPA consists of Java Persistence API, query language and object/relational mapping tool. If you are you using JEE 7 you will have to use the JPA 2.1.

Here are the main new features of JPA 2.1:

  • Converters - The Converters allows the custom code conversions between database and object types.
  • Criteria Update/Delete - Now you can use the Criteria API for bulk updates and deletes.
  • Stored Procedures - Stored procedure can be used.
  • Schema Generation - It allows the schema generation.
  • Entity Graphs - allow partial or specified fetching or merging of objects.
  • JPQL/Criteria enhancements - Now JPA 2.1 supports arithmetic sub-queries, generic database functions, join ON clause, TREAT option.
Advertisement

Here are the tutorials of JPA 2.1:

Beginning JPA 2.1

Introduction to Java Persistence API

The Java Persistence Query Language

  • Introduction to Java Persistence Query Language
  • Creating Queries Using the Java Persistence Query Language
  • Example of Named Queries
  • Queries with Conditional Expressions
  • Bulk Updates and Deletes Query examples
  • FROM Clause and its examples
  • Path Expressions Examples
  • WHERE Clause examples

Criteria API

  • Introduction to the Criteria and Metamodel APIs
  • Example of Criteria API
  • Example of String-Based Criteria Queries
  • How to restrict Criteria Query Results

Entity Graphs

  • What is Entity Graphs?
  • Example of Entity Graphs

Using Second-Level Cache with Java Persistence API Applications

  • Understanding Secondary-Level Cache with JPA
  • Why to use Secondary Level Cache
  • Secondary-Level Cache Implementations
  • Example of Secondary-Level Cache