How to map Composite Primary Key to Entity Class in JPA Hibernate

In this example I am going to tell you how to map composite primary key to entity class in your JPA Hibernate entity class. Composite primary key is a combination of two or more columns made together as a primary key. Therefore the combination of column values will be as a unique instead of having a single column value as…

Java and XML based JPA Persistence Unit Configurations

Here in this tutorial I am going to tell you how to configure Persistence Unit for JPA (Java Persistence API). Here I am going to show you both XML and Java based configurations for persistence unit in JPA. This is a pure Java application and I am not using Spring framework for this example. A persistence unit defines the details…

What Is The Use Of @Temporal Annotation In JPA

@Temporal Annotation In this tutorial I am going to tell you what is the use of @Temporal annotation in JPA (Java Persistence API). @Temporal is a JPA annotation and generally specified only for persistent fields or properties of type java.util.Date and java.util.Calendar. Generally you can use @Temporal annotation on the date or calendar field in entity classes while you are mapping…

JPA Criteria API

Introduction This tutorial will show you how to use JPA(Java Persistence API) Criteria API Queries for selecting data from database. The Java Persistence API (JPA) is a Java specification for accessing, persisting, and managing data between Java objects / classes and a relational database. The Criteria API is used to define queries for entities and their persistent state by creating…

Many to Many Mapping in JPA

In this example I am going to show you how we can implement Many to Many(@ManyToMany) relationship using JPA persistence API in Java. The Java Persistence API (JPA) is a Java specification for accessing, persisting, and managing data between Java objects / classes and a relational database. The JPA is used to reduce the burden of writing codes for relational…

One to One Mapping in JPA

In this example I am going to show you how we can implement One to One(@OneToOne) relationship using JPA persistence API in Java. The Java Persistence API (JPA) is a Java specification for accessing, persisting, and managing data between Java objects / classes and a relational database. The JPA is used to reduce the burden of writing codes for relational…

One to Many Mapping in JPA

In this example I am going to show you how we can implement One to Many(@OneToMany) relationship using JPA persistence API in Java. The Java Persistence API (JPA) is a Java specification for accessing, persisting, and managing data between Java objects / classes and a relational database. The JPA is used to reduce the burden of writing codes for relational…

Many to One Mapping in JPA

In this example I am going to show you how we can implement Many to One(@ManyToOne) relationship using JPA persistence API in Java. The Java Persistence API (JPA) is a Java specification for accessing, persisting, and managing data between Java objects / classes and a relational database. The JPA is used to reduce the burden of writing codes for relational…

JPA Inheritance Strategy : Table Per Concrete Class Hierarchy (TABLE_PER_CLASS)

JPA comes with a provision to create tables and populate them as per the Java classes involved in inheritance. JPA offers basically three different approaches to map hierarchical classes – classes involved in inheritance with database tables. Observe, in the above hierarchy, three classes are involved where Person is the super class and Student and Teacher are sub-classes with their…

JPA Inheritance Strategy : Table Per Sub-Class Hierarchy (JOINED)

JPA comes with a provision to create tables and populate them as per the Java classes involved in inheritance. JPA offers basically three different approaches to map hierarchical classes – classes involved in inheritance with database tables. Observe, in the above hierarchy, three classes are involved where Person is the super class and Student and Teacher are sub-classes with their…