From the course: Java Persistence with JPA
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Solution: Create simple employee, company, and salary classes - Java Tutorial
From the course: Java Persistence with JPA
Solution: Create simple employee, company, and salary classes
(jaunty music) - [Instructor] Let's take a look at how I solved the challenge just to create foundational Java classes needed for the course project. First, let's take a look at company. Notice on line seven, I'm using the @Entity id to identify this class as an entity so that it can be mapped to a table. That table name I'm overriding to be companies with an s instead of company using this @Table annotation. Scroll down. Here on line 14, I'm creating the id attribute and I'm denoting it as the primary key using this @Id annotation on line 11. Look here on line 12. I'm using the generated value annotation and I'm setting the strategy to auto. This means the primary key will be automatically generated. Here on line 13, I'm overriding the column name to be company_id instead of id. Let's scroll down, for the remaining attributes, name, city, state, zip code, and country, notice I'm using the @Column annotation,…
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.
Contents
-
-
-
Exploring the history of JPA3m 48s
-
(Locked)
Leveraging Object-Relational Mapping (ORM)2m 20s
-
(Locked)
Understanding JPA and its benefits2m 10s
-
(Locked)
Demo: Configuring JPA4m 1s
-
(Locked)
Demo: Reviewing JPA annotations4m 11s
-
(Locked)
Challenge: Create simple employee, company, and salary classes3m 38s
-
(Locked)
Solution: Create simple employee, company, and salary classes3m 43s
-
-
-
-
-
-