Jak radzić sobie z łączeniem zapytań w Hibernate i Spring z adnotacjami?

Zajmuję się tworzeniem aplikacji za pomocą Spring i Hibernate z MySQL. Jestem nowym użytkownikiem Hibernate i wykonałem podstawowe zadania ...

Teraz muszę zastosować sprzężenia w kwerendzie wyboru, aby uzyskać dane z wielu tabel przy użyciu adnotacji. Szukałem go, ale wciąż nie miałem pojęcia ...

Oto moje tabele bazy danych i klasy bean:

Table 1: 'employee_info' ( id, empid, empname, doj and jobtitle )

Table 2: 'employee_login' ( username, password, status and empid )

A moje klasy fasoli to:

EmployeeInfoForm.java

@Entity()
@Table(name = "employee_info")
public class EmployeeInfoForm {

@Id
@GeneratedValue
@Column(name = "id", unique = true, nullable = true)
private int id;

@Column(name = "empId")
private int empId;

@Column(name = "empname")
private String empName;

@Column(name = "doj")
private Date empDoj;

@Column(name = "jobtitle")
private String empJobTitle;

public int getEmpId() {
    return empId;
}

public void setEmpId(int empId) {
    this.empId = empId;
}

public void setEmpDoj(Date empDoj) {
    this.empDoj = empDoj;
}

public String getEmpName() {
    return empName;
}

public void setEmpName(String empName) {
    this.empName = empName;
}

public Date getEmpDoj() {
    return empDoj;
}

public void setEmp_Doj(Date empDoj) {
    this.empDoj = empDoj;
}

public String getEmpJobTitle() {
    return empJobTitle;
}

public void setEmpJobTitle(String empJobTitle) {
    this.empJobTitle = empJobTitle;
}


}

EmployeeLoginForm.java

@Entity()
@Table(name = "employee_login")
public class EmployeeLoginForm {

@Id
@Column(name = "username")
private String empUserName;

@Column(name = "password")
private String empPassword;

@Column(name = "status")
private String empStatus;

@Column(name = "empid")
private int empId;

public String getEmpUserName() {
    return empUserName;
}

public int getEmpId() {
    return empId;
}

public void setEmpId(int empId) {
    this.empId = empId;
}

public void setEmpUserName(String empUserName) {
    this.empUserName = empUserName;
}

public String getEmpPassword() {
    return empPassword;
}

public void setEmpPassword(String empPassword) {
    this.empPassword = empPassword;
}

public String getEmpStatus() {
    return empStatus;
}

public void setEmpStatus(String empStatus) {
    this.empStatus = empStatus;
}

}

Wymaganie:

Chcę wybrać polaempid, empname, jobtitle zpracownik_info i polestatus zpracownik_login tabela, gdy empid pasuje do obu tabel ...

Pomóż mi ukończyć pracę ...

Wszelkie sugestie i wskazówki są mile widziane ...

questionAnswers(3)

yourAnswerToTheQuestion