JPA

Print the objectives

  Take a beta test

This exam focuses on Java Persistence API 1.0 (JPA) as described in the EJB 3 Specification. It covers JPA object/relational mapping with annotations, JPQL syntax, queries, concurrency and other concepts. Pojo, JDBC, XML, SQL, database and DDL concepts are out of scope since they are tested in separate exams.

With JPA you can define the object relational mapping either using annotations or XML description. This exam only focuses on annotations. If you want to know more about XML mapping you can check the specification, but this exam will not cover it.

Note to question authors: Please don't use any implementation specific question (TopLink, Hibernate, OpenJPA...)

Need help passing this exam? Check out our Coached e-Learning JPA Fundamentals course.

  Released  Beta  Frozen  

General

 
 

JPA  1 question

9 6 11

Entities  1 question

  • Understand how to turn a Pojo into an entity.
  • Explain the effect of implementing the Serializable interface in an Entity.
  • Identify the requirements of an Entity
  • Know how primary key and entity identity are related.
  • Describe what can be persisted in an entity (fields, properties...).
  • Describe the purpose of equals() and hashcode() methods when using collections.
21 17 2

Mapping

 
 

General  1 question

  • Know what ORM is and how it is used in JPA.
  • Understand the mechanism of coding by exception and when you need to add custom code when the default is inadequate.
  • Explain how mapping is made in JPA using annotations.
  • Understand how attributes (java primitives, String, Integer...) and collections (Set, Map...) are mapped.
7 1 5

Identification  2 questions

  • Differentiate entity identification (@Id, @IdClass, @EmbeddedId).
  • Compare identifier generation policies (@GeneratedValue: TABLE, SEQUENCE, IDENTITY, AUTO).
  • Describe the differences between @SequenceGenerator and @TableGenerator.
10 8 4

Annotations  3 questions

  • Detect class annotations (@Entity, @Table).
  • Understand the basic field annotations (@Column, @Basic, @Transient).
  • Distinguish the date formats (@Temporal)
  • Know how to map enumerations.
  • Handle versionning (@Version).
  • Map large objects (@Lob).
27 19 12

Entity operations

 
 

Entity Manager  2 questions

  • Understand the role of the Entity Manager.
  • Write CRUD operations with Entity Manager (persist, remove...).
  • Describe how persistence units fit in JPA.
  • Name exceptions that are handled by the entity manager (PersistenceException, EntityExistsException, EntityNotFoundException, )
17 23 10

Persistence context  1 question

  • Understand persistence context lifetime (scoped to a transaction or extends beyond a transaction).
  • Know what an extended persistence context is.
3 17 3

Entity instance's life cycle  2 questions

  • Identify entity states (persistent, transient, detached).
  • Define state transitions of an entity.
  • Explain callback annotations (@Pre and @Post annotations)
  • Establish synchronization of entities with the database (after being detached entities have to be merged to be synchronized).
14 3 4

Entity Listener  1 question

  • Know how to implement an entity listener.
3 12 3

Concurrency  1 question

  • Explain optimistic locking.
  • Identify the lock modes.
  • Know how to deal with concurrency.
  • Determine which exceptions are thrown when using locking and concurrency.
6 10 2

Relationships

 
 

Associations  3 questions

  • Map unidirectional and bidirectional one-to-one, one-to-many, many-to-many associations.
  • Use @Embedded and @Embeddable for aggregations.
  • Explain all the cascading actions that can occur.
  • Define fetch attributes (LAZY and EAGERLY)
  • Implement join tables (@JoinTable, @JoinColumn)
  • Order collections with @OrderBy annotation.
  • Understand the defaults when mapping associations.
16 7 10

Inheritance  2 questions

  • Identify all the inheritance strategies (SINGLE_TABLE, JOINED, TABLE_PER_CLASS).
  • Discuss the pros and cons of the different strategies.
  • Use annotations to map inheritance (@MappedSuperclass, @Inheritance).
  • Perform polymorphic associations.
  • Understand the use of discriminators (@DiscriminatorColumn, @DiscriminatorValue, DiscriminatorType).
7 25 7

Object retrieval

 
 

JPQL  3 questions

  • Know the syntax of JPQL (select, from, where, sorting, aggregate functions)
  • Explain how to use parameters in a JPQL query.
  • Describe the different join policies (inner join, left outer join, fetch join)
  • Develop polymorphic queries.
  • Functions and expressions (between, in, like, empty, member)
    • String functions (concat, lower, length, trim)
    • Arithmetic functions (abs, sqrt, size)
    • Aggregate functions (avg, count, max, min, sum)
    • Datetime functions (current_date, current_time, current_timestamp)
15 6 14

Query  2 questions

  • Apply the Query API (Query ).
  • Distinguish Queries, Named queries and Native Queries (NamedNativeQuery, NamedQuery).
  • Understand how to use flush mode.
  • Resolve exceptions thrown by queries.
14 5 1

Others  1 question

  • Work with pagination (returning X rows at a time).
  • Use bulk operations (updates and deletes).
4 11 3

Runtime environment

 
 

General  1 question

  • Spot the differences of using JPA in a Java EE vs Java SE application (EntityManagerFactory, injection through @PersistenceContext...).
  • Understand when to use resource local entity manager.
  • Describe the packaging of a JPA application.
  • Discuss the structure and role of persistence.xml file.
  • Differentiate container managed transaction and application managed transaction.
  • Know how to deploy a JPA application (needed files in the classpath or in the JAR like persistence.xml).
10 5 3

Java EE  1 question

  • Explain the design pattern IoC.
  • Use @PersistenceContext for injection.
  • Obtain an entity manager in Java EE.
2 5 4

Java SE  1 question

  • Use the EntityManagerFactory to get a Entity Manager.
  • Understand how to bootstrap JPA application in Java SE.
  • Define ACC (Application Client Container) and how to use JPA.
3 0 4

Exam information

  • 43 minutes
  • 29 questions (470)
  • 70% required
  • +4 √
  • - 15  points
  • 15 day delay
  • status: beta