2
Good morning.
I’m having trouble performing a query in the database where my Employee entity has 2 mappings @Manytomany and 1 mappings @Manytoone. When performing a query the Employee and Projects data are returned without major problems. The relational attributes of Manytomany being a problem. To make the insertion is occurring ok. To search the base for a problem. Can someone please help? Thank you
@Entity
@Table(name = "employee")
@JsonView
public class Employee implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id_employee;
@NotNull
@Column(name = "name", length = 120)
private String name;
@NotNull
@Column(name = "role", length = 100)
private String role;
@NotNull
private Double salary;
@NotNull
@Column(name = "manager", length = 120)
private String manager;
private int gcm;
@NotNull
@ManyToOne
private Projects project;
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinTable(name = "employee_skill",
joinColumns = @JoinColumn(name = "id_employee"),
inverseJoinColumns = @JoinColumn(name = "id_skill")
)
private List<Skill> skill;
@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name = "employee_certification",
joinColumns = @JoinColumn(name = "id_employee"),
inverseJoinColumns = @JoinColumn(name = "id_certification")
)
private List<Certification> certification;
}
Skill class
@Entity
@Table(name = "skill")
@JsonView
public class Skill implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id_skill;
@NotNull
private String descricao;
@ManyToMany(mappedBy = "skill", fetch = FetchType.LAZY)
private List<Employee> employee;
public Skill(){}
}
Class Certification
@Entity
@Table(name = "certification")
@JsonView
public class Certification implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id_certification;
@NotNull
private String descricao;
@ManyToMany(mappedBy = "certification", cascade = CascadeType.ALL)
private List<Employee> employee;
public Certification(){}
public Certification(String descricao){
this.descricao = descricao;
}
}
Class Projects
@Entity
@Table(name = "projects")
@JsonView
public class Projects implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id_project;
@Column(name = "name", length = 150)
private String name;
@Column(name = "customer", length = 100)
private String customer;
private Double valueOfProject;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "dt_Begin")
private Calendar dtBegin;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "dt_End")
private Calendar dtEnd;
@OneToMany(mappedBy = "project")
private List<Employee> employee;
public Projects(){}
}
I could post on the answer, where you make the flame of Employe and what would be the errors occurred
– Weslley Barbosa