Skip to Main Content
Developing Middleware in Java EE 8
book

Developing Middleware in Java EE 8

by Abdalla Mahmoud
June 2018
Intermediate to advanced content levelIntermediate to advanced
252 pages
6h 45m
English
Packt Publishing
Content preview from Developing Middleware in Java EE 8

Step 4: Creating a data access object

Now to the key part, where we will mix the knowledge we learned in  Chapter 2, Dependency Injection Using CDI 2.0, to use persistence APIs. As you may know, any data access layer includes what's called data access objects; those objects are responsible for performing basic data housekeeping operations such as inserting, retrieving, modifying, and deleting rows from the database.

To do this in JPA, we have to first obtain an instance of the persistence provider object that implements the fundamental JPA EntityManager interface. To obtain such an object, the following code is used:

EntityManagerFactory emf = Persistence.createEntityManagerFactory("jpa-examplesPU"); EntityManager em = emf.createEntityManager(); ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Java EE Development with WildFly

Mastering Java EE Development with WildFly

Luca Stancapiano

Publisher Resources

ISBN: 9781788391078Supplemental Content