Page 1

Course information Java Persistent API 2.0 (JPA) JAVAEE-04.07

Duration: 2 days Course Description This course teaches the student all 'ins and outs' of the Java Persistent API (JPA)

Course Objectives This comprehensive JPA class provides complete coverage of the world of JPA 2.0 Entities. With a strong hands-on character and focussed for you to become a productive with JPA on your projects immediately. The course contains many (many!) ready-to-use demos. this course make you competent and confident in JPA 2.0 so that you can use JPA on your projects the minute you leave the class room. Some of the topics • JPA Architecture and Design • ORM capabilities • Use of the Bean Validation Framework (JSR-303) • JPA and Software Design • Controlling the life-cycle of entities • All different mapping strategies (multiple tables, associations, inheritance etc.) • Using different query APIs (JPA, criteria, native) • The JPA Query language • Performance, caveats dos and don`ts etc.

Who can benefit? The level of this course is intermediate to advanced. It is specifically designed for developers that need to get up and running with JPA Programming Skills as soon as possible. For this reason this course is very hands-on oriented. Students should have a good working knowledge of Java SE

1 | Java Persistent API 2.0 (JPA)

©2010 IT Education


Course information Java Persistent API 2.0 (JPA) JAVAEE-04.07

Workshop overview Entities (rev:492 (rev:4929 4929) Introduction to JPA 2.0 • Explain Object to Relational (O/R) Mapping (ORM) • Explain the Java Persistence Architecture • Explain history and different version of JPA • List benefits of using Entities • Discuss the goals of Entities • List key functionalities of Entities • List the different Persistence types (entity and embeddable objects) • OO Design/Domain Model and ORM • Avoiding the "Anemic domain model" anti-pattern Getting started with Entities • Understand the nuts and bolts of Entities • Understand how to map an Entity to the database • Understand the configurations involved and their relationships • List different ways of packaging Entities • Understand the overall syntax of the peristence.xml Configuration file • Introduce the javax.persistence.EntityManager • Understand one way of obtain a reference to the Persistence Context • Supply a basic example of using Entities Basic ORM • Configure persistent classes • Configure persistent state of a class • Understand the requirements on a persistent entity class • Understand Object identity in JPA • Discuss object identity and a caveat in hashCode and equals • implementations • Discuss different ways of generating unique numbers for keys • Introduce derived identities • Understand how to influence mapping to columns • Understand how to map properties of a class to multiple tables • Understand how to map composition using Embeddable classes • Map collections of value and embeddable types • Adding validation using Bean Validation Framework (JSR 303)

2 | Java Persistent API 2.0 (JPA)

©2010 IT Education


Course information Java Persistent API 2.0 (JPA) JAVAEE-04.07 Entity associations (relations) • List the different types of associations • Understand the difference between bi and unidirectional associations • Understand how to map bi and unidirectional one to one, many to one and • one to many associations • Understand how to and when to use join tables • Using foreign key mapping in uni and bi directional associations • Understand how to map many-to-many associations • Understand how to cascade over associations • Using orphan removal Mapping Inheritance • Discuss the three Inheritance ORM strategies • Discuss the Single Table Inheritance Pattern (aka table per class hierarchy) • Discuss the Class Table Inheritance Pattern (aka table per subclass) • Discuss the Concrete Table Inheritance Pattern (aka table per concrete • class) • Discuss Strength and weaknesses of each strategy • Introduce the concept of Mapped Superclasses • Understand how to configure these mappings • Understand the concept of a discriminator

Controlling Entity lifelife-cycle(rev:) Controlling the life-cycle • Attached and Detached objects • Control the life-cycle of entities (create, remove etc) • Understand merging entities • Use the Cache API • Entity Listeners and Callback methods • Introduction to different queries (criteria, typed, named etc=) • Introduction to criteria queries • Using Native queries Using JPA Query Language • Introduce the JPA QL • Understand the different statement types (SELECT, UPDATE/DELETE) • Understand the JPA QL syntax • Using the FROM clause (ranges, Using inner, left outer and fetch joins) • Using the WHERE clause (conditional, between, in, like, exists/all/any, case • etc) • Using sub queries • Using parameters 3 | Java Persistent API 2.0 (JPA)

©2010 IT Education


Course information Java Persistent API 2.0 (JPA) JAVAEE-04.07 • •

Using GROUP BY and HAVING and aggregate functions (SUM, AVG, MAX, MIN, etc)

Concurrency • Optimistic versus pessimistic concurrency • Using pessimistic locking • Using lock properties • Using Optimistic locking • Using the version attribute • Understanding different Lock modes (OPTIMISTIC/FORCE_INCREMENT , PESSIMISTIC_READ/WRITE/FORCE_INCREMENT)

Hands-on lab exercises Exercise 1 - Map a class (Member) to the database The objective is to map a class with fields of different types to the database. Exercise 2 - Implement a composition The objective of this exercise is to understand how to use EJB 3.0 Embeddable classes. Exercise 3 - Map different associations The objective is to map different association types to the database in two real life use cases. Exercise 4 - Map specializations The objective is to understand how to map class inheritance to the database.

P.O. Box 88 · 3750 GB Bunschoten · The Netherlands +31.33.44.80.160 · info@iteducation.nl · www.iteducation.nl Trade Register: 32147657 · VAT: NL0681.57.897.B01 · ING Bank: 4238201

4 | Java Persistent API 2.0 (JPA)

©2010 IT Education

Java Persistent API 2.0 (JPA)  

This course teaches the student all 'ins and outs' of the Java Persistent API (JPA)

Read more
Read more
Similar to
Popular now
Just for you