Skip to content

Commit

Permalink
Part 3
Browse files Browse the repository at this point in the history
  • Loading branch information
JennGoldring committed Jun 12, 2023
1 parent 68b4600 commit f8559d9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
public abstract class AbstractEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Integer id;
public int id;
// public String name;

public void setId(Integer id) {
public void setId(int id) {
this.id = id;
}

public Integer getId() {
public int getId() {
return id;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public class Employer extends AbstractEntity {
@Size(max = 50)
private String location;

@OneToMany(mappedBy = "employer")
private List<Skill> skills;
// @OneToMany(mappedBy = "employer")
// private List<Skill> skills;

@OneToMany
@JoinColumn(name = "employer_id")
Expand All @@ -42,7 +42,7 @@ public void setJobs(List<Job> jobs) {
this.jobs = jobs;
}
@Override
public Integer getId() {
public int getId() {
return super.getId();
}
}
23 changes: 11 additions & 12 deletions src/main/java/org/launchcode/techjobs/persistent/models/Skill.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
package org.launchcode.techjobs.persistent.models;

import javax.persistence.Id;
import javax.persistence.Entity;
import javax.persistence.GenerationType;
import javax.persistence.ManyToOne;
import javax.persistence.Id;
import javax.validation.constraints.NotBlank;
@Entity
public class Skill extends AbstractEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private int id;

@NotBlank
private String description;
@ManyToOne
private Employer employer;
// @ManyToOne
// private Employer employer;

public Skill () {
}

public Integer getId(){
public int getId(){
return id;
}
public String getDescription() {
Expand All @@ -30,10 +29,10 @@ public void setDescription(String description) {
this.description = description;
}

public Employer getEmployer() {
return employer;
}
public void setEmployer(Employer employer) {
this.employer = employer;
}
// public Employer getEmployer() {
// return employer;
// }
// public void setEmployer(Employer employer) {
// this.employer = employer;
// }
}
15 changes: 5 additions & 10 deletions src/main/resources/templates/add.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,11 @@ <h1>Add Job</h1>
</div>

<div class="form-group">
<label for="employer">Employer</label>
<!-- <select name="employerId">-->
<select class="form-control" th:field="${job.employer}">
<option value="">Select an employer</option>
<option th:each="employer : ${employers}" th:value="${employer.id}" th:text="${employer.name}"></option>
<!-- <option value="">Select an employer</option>-->
<!-- <option th:each="employer : ${employers}" th:value="${employer.id}" th:text="${employer.name}"></option>-->
<!-- <option th:each="employer : ${employers}"-->
<!-- th:text="${employer.name}"-->
<!-- th:value="${employer.id}"></option>-->
<label th:for="employer">Employer</label>
<select name="employerId">
<option th:each="employer : ${employers}"
th:text="${employer.name}"
th:value="${employer.id}"></option>
</select>
<a th:href="@{'/employers/add'}">Add Employers</a>
</div>
Expand Down

0 comments on commit f8559d9

Please sign in to comment.