JPA is the standard Java ORM specification. In this module, we will explore entity annotations, query configurations, and primary key lookups.

9.1. JPA Entity mappings & JPQL Query syntax

Definition: Entity mapping maps classes to tables. JPQL is an object-oriented query language that queries Java entities instead of database tables.

Core Working Principles:

TypedQuery<Book> query = em.createQuery(
    "SELECT b FROM Book b WHERE b.author = :author", Book.class);
query.setParameter("author", "Author");
List<Book> books = query.getResultList();
5-Marks Exam Scoring Points
  • @Entity registers a Java class as a persistent database table.
  • @Id identifies the primary key field.
  • JPQL is platform-independent; the provider translates it to SQL at runtime.