From the course: Java Persistence API (JPA): 1 The Basics
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Updating objects - Java Tutorial
From the course: Java Persistence API (JPA): 1 The Basics
Updating objects
- [Narrator] There's always a need to update data once it's persisted. For example, the owner of an application may change or a ticket status may change to resolved. Let's look at the steps necessary to update a managed entity using the entity manager. Updating is always a necessary operation. Now, what is interesting is that there's no update method in the entity manager class. An update automatically happens in a manged entity whenever one of its attributes value changes. The first step in updating an entity is to first find the entity using the entity manager find method. So let's look at a hands-on demo. So open the begin files for chapter two, video five. So if you see something like this, remember to click on setup SDK and click okay. And always make sure that you enable auto import for your Maven project. So first, let's look at Trackzilla controller. That is under source, main, Java, controller. And we are looking for the update application. Here it is on line 38. So the…
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.