From the course: Java Persistence with JPA and Hibernate

Unlock the full course today

Join today to access over 23,400 courses taught by industry experts.

Bootstrapping JPA and Hibernate: Creating the EntityManager

Bootstrapping JPA and Hibernate: Creating the EntityManager - JPA Tutorial

From the course: Java Persistence with JPA and Hibernate

Bootstrapping JPA and Hibernate: Creating the EntityManager

- [Instructor] The first step to Bootstrap Jakarta persistence and Hibernate is to create the configuration. That can be done either using the persistence.xml file or programmatically. You can follow the previous video if you haven't already done this. The next step in boostrapping is to configure the entity manager. With the persistence.xml file in place, now let's check out how to create the entity manager. Entity Manager is a handle to the persistence context. That means it defines how your application should give instructions to the persistence context in order to interact with the underlying database. In the main class here, what we need to create now is an entity manager. This entity manager will represent the context. To get an entity manager, I need something known as an EntityManagerFactory. EntityManagerFactory, call it emf, and import it. Factories in Java are there to create objects when you need them, so EntityManagerFactory can create entity managers. There are two ways…

Contents