From the course: Learning Java Enterprise Edition

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

JPA in practice: Entity

JPA in practice: Entity - Java EE Tutorial

From the course: Learning Java Enterprise Edition

Start my 1-month free trial

JPA in practice: Entity

- [Instructor] In this video, you'll see how to use JPQL queries to query the data store and how the entity manager API means that we don't need to write boilerplate code that performs simple CRUD functionality. Let's go back to the Cargo Tracker code and have a look at how we're using JPA. We will start with a Cargo entity, which you will be familiar with by now. As you can see, the class is annotated Entity. This identifies as an entity, and by default, it relates to a table in the database called Cargo. Moving down, you can see some NameQueries defined. We will come back to those later. Further down, there are fields marked with JPA annotations. The first field we come across is the Id field. This field is annotated Id and GeneratedValue. This identifies this field as a primary key. When this entity is persisted in the database, a value is automatically generated. Let's scroll down further. Looking at the next field, the TrackingId field, we can see this field is annotated…

Contents