From the course: Java EE 8 Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Entity mapping - Java EE Tutorial
From the course: Java EE 8 Essential Training
Entity mapping
- [Instructor] JPA providers use entity annotations to determine how to persist our entities to a database. Let's take a look at some of these annotations and map one of our entities. So here we have the catalog item class. It's just a basic POJO and we're going to turn this class into an entity by just adding the entity annotation. Another class-level annotation that we can add to our entities is the table annotation, and this allows us to specify the name of the table within the relational database that corresponds with this entity. So there you can see we are mapping the catalog item class to the catalog_item table within our database. Now we can move onto the field-level annotations, so we're going to use the ID annotation to indicate that the item ID is our primary key on this entity, and we can go ahead and specify the column name here. We'll just call this the catalog item underscore ID column. You'll notice it…
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.