JPA 2.0

Well, if you are here, then definitely you are interested in Object to Relation mapping and you have heard of Java Persistence API. It is the specification provided by Java Enterprise Edition which have different implementations. JPA is standard part of Java EE and implementers need to follow the rules specified by JPA. This tutorial series is created using JPA 2.0 as specification and eclipseLink as implementation. These articles will be very useful if you are preparing for JPA certification.

Beginning JPA

  • Creating a jpa project in eclipse
    • The article describes how to create a jpa project in eclipse with the help of eclipseLink implementation and mysql database.
  • Entities in JPA
    • The article describes about entities in general and the meaning of entities in jpa. Characteristics of entities in jpa are described with an example
  • JPA Architecture
    • The article introduces major components in jpa architecture and explains their role with the help of code snippets. JPA architecture diagram is provided.
  • A simple CRUD example
    • This article demonstrates the jpa crud example with mysql database and eclipse as IDE.
  • Automatic ID generation with table generator strategy
    • The article describes jpa table generator with @TableGenerator annotation. An example of jpa table generator is provided for easy understanding.

Entity Relationships and mapping

  • Many to One Mapping

    • The article focuses on jpa many to one mapping with simple example and explanation about the jpa entities and corresponding database tables and relations.
  • One to One Mapping

    • The article describes the concept of jpa one to one mapping and provides an example along with database relationship diagram.
  • One to Many Mapping

    • The article explains the relation between jpa one to many mapping and many to one mapping with the help of diagrams and examples..
  • Many to Many Mapping

    • The article explains the concept of jpa many to many mapping with the help of diagram and example.
  • Embedding objects in entities

    • The article describes the user of jpa embeddable annotation and explains how embedded objects can be used by owning entities in embedded object relationship
  • Overriding attributes in entities

    • The article explains how to map fields names of embedded objects using jpa AttributeOverride annotation to database tables if columns names are different..
  • Using element collections in entities

    • The article shows the purpose of jpa ElementCollection annotation and how it can be used in mapping collections of embeddable objects for entities.
  • Using Secondary Tables

    • The article describes the concept of secondary tables and elaborates it with JPA SecondaryTable Annotation Example..
  • Using MapKeyColumn annotation

    • The article provides JPA MapKeyColumn Annotation Example to demonstrate how keys are stored in database when map relationship is used between entities.
  • Using JoinColumns for composite keys

    • The article describes JoinColumns annotation and gives demonstration of the same with the help of JPA JoinColumns Annotation Example along with database diagram.
  • Using OrderColumn annotation

    • The article shows how order of insertion into a list can be maintained when it is retrieved from database.
  • Using MapsId Annotation

    • MapsId annotation in JPA is used in ManyToOne or OneToOne relationships when mapping using EmbeddedId is involved. Let us see a JPA MapsId example demo.

 Understanding EntityManagers

  • Transaction scoped Entitymanagers.

    • The article introduces to transaction scoped entitymanager and how it acts in a container managed persistence context.
  • Extended Entitymanagers

    • The article describes the concept of extended entitymanager and how stateful session beans come into play when extended entitymanager is used in java EE app
  • Application managed Entitymanagers

    • The article describes about the application managed entitymanager in jpa and how it can be created in applications.
  • Choosing an Entitymanager for a scenario

    • The article describes pros and cons of each type of entity manager and helps make decision for choosing entitymanager for different scenarios in application.
  • Common entitymanager operations

    • The article explains about jpa entitymanager operations and provides an example of each operation along with its explanation.

Java Persistence API Query Language

  • JPA Query Language.

    • The article introduces the features and general syntax for JPA Query Language and provides a simple example and how queries can be executed..
  • JPA Select clause

    • The article introduces to jpa select clause which is used to select entities in jpql. It provides general syntax and example of jpa select clause.
  • Using query parameters

    • The article describes how jpa query parameters can be used whenever some information needs to be passed to jpql queries at runtime.
  • Using Joins 

    • The article introduces to jpa joins and explains the concept..
  • Creating Inner Joins

    • The article describes jpa inner joins and compares them with sql joins. It describes similarities and differences between them with an example.
  • Creating Outer Joins

    • The article describes jpa outer joins and how they can be applied to different entities and results are retrieved. SQL joins and jpa outer joins are compared.
  • Using Case Expressions

    • The article describes how results can be converted from one form to another by using jpa case expressions and provides an example.
  • Ordering results with Order By clause.

    • This article demonstrates how results from a jpql query can be ordered by some field using jpa order by clause.
  • Grouping results with group by clause.

    • This article demonstrates how results can be grouped according to some criteria by using jpa group by clause in jpql.
  • Generating reports from query results.

    • The article describes how reports in jpa can be generated by selecting multiple fields from various entities and how results are retrieved and iterated.

Criteria API

 Creating Compound Primary Keys:

Entity inheritance in jpa

Miscellaneous

  • JPA Lifecycle callback methods
    • The article introduces to jpa lifecycle callback methods and provides an example which describe the working and entity lifecycle.
  • JPA EntityListeners
    • The article introduces jpa entitylisteners and how entity lifecycle callback methods can be implemented in jpa entitylisteners outside entities.
  • Bean validation using constraints
    • This article demonstrates how constraints can be used along with jpa bean validation and how constraints can be retrieved when doing jpa bean validation.
  • Creating custom constraints
    • The article explains creating custom constraints for bean validation and provides an example along with output.
  • Caching in JPA
    • The article gives a brief introduction to jpa caching and different levels of jpa cache when used in an application.
  • Using @Cacheable annotation
    • The article describes how to configura cache and use it in applications with the help of a JPA Caching Example
  • OCEJPAD certification Exam
    • Here is how I became Oracle Certified Expert Java EE 6 Java Persistence API Developer
  • OCEJPAD reference:
    • Some short notes compiled from oracle official documentation for preparing for OCEJPAD.

Spring Data:

  • Introduction to Spring Data:
    • This article gives a brief introduction of spring data and its variants spring data jpa and spring data mongodb.
  • Spring Data Interfaces:
    • The article gives brief overview of spring data commons interfaces which can provided generic functionalities to store specific interfaces
  • Spring Data JPA Interfaces:
    • The article gives brief introduction spring data jpa interfaces and its default provided implementation.
  • Spring Data JPA Hello World:
    • The article demonstrates CrudRepository in spring data jpa hello world example.
  • Query Methods:
    • The article introduced spring data jpa query methods and provides examples along with program and its output.
  • Sorting in Spring Data JPA:
    • The article helps understand how results fetched from query methods can be used for sorting in spring data jpa. We do not have to write explicit JPQL,
  • Spring Data JPA Pagination:
    • The article goes further and elaborates sorting and pagination in spring data jpa along with a simple example and working code
The following two tabs change content below.
Prasad Kharkar is a java enthusiast and always keen to explore and learn java technologies. He is SCJP,OCPWCD, OCEJPAD and aspires to be java architect.

4 comments for “JPA 2.0

  1. Arsene
    March 25, 2016 at 1:30 am

    Good job but i’m frustating to not see a very example of using JPA in a same project with multiples databases (i don’t want to use spring).
    Regards.

    • March 28, 2016 at 8:52 am

      I will create an example soon and post. Thank you for your feedback.

  2. July 13, 2016 at 2:43 pm

    is it possible to create Forms (insert, delete, update form) from table (internally java services, html forms, js actions will be created ?) in JPA

  3. Sameer S Argade
    September 9, 2016 at 6:42 am

    Is there a way to log the entity failed to insert during a bulk or batch insert?
    Can we pin point which entity failed to persist?

    Regards

Leave a Reply

Your email address will not be published. Required fields are marked *