From the course: Java Persistence API (JPA): 1 The Basics
Unlock the full course today
Join today to access over 22,700 courses taught by industry experts or purchase this course individually.
Persisting Objects - Java Tutorial
From the course: Java Persistence API (JPA): 1 The Basics
Persisting Objects
- [Instructor] So, now let's add the code for persisting an application using the Entity Manager. So, we are using the Entity Manager and we are calling the Persist Method on the Entity Manager and we're passing in our application. Now before the application is persisted, it is just an object living in memory. After persisting the object it becomes a Managed Entity. So, now let's launch the application and see this code in action. When using IntelliJ to launch the Web application we click in the upper right hand corner, on this green icon. And we see the log statements as the application starts. So there are two ways we are going to test creating an application object. First, let's look at our unit test. So it's Trackzilla controller test and that is actually found here, in our test folder. Underneath the controller folder. You can double click on that. And so we have a unit test for adding an application, so let's take a look at that. So, here, on line 30. We're creating a mock…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.