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

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,…

Contents