我使用Spring开发应用,并与MySQL休眠。 我是新来Hibernate和做基本任务...
现在我需要申请在联接选择查询,从多个表中使用注释获取数据。 我已经寻找它但我仍然没有得到任何想法...
我在这里的数据库表和bean类:
Table 1: 'employee_info' ( id, empid, empname, doj and jobtitle )
Table 2: 'employee_login' ( username, password, status and empid )
而我的bean类有:
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;
}
}
需求:
我想选择字段EMPID,empname,JOBTITLE从employee_info和现场状态从当EMPID两个表上匹配employee_login表...
请帮我完成我的工作......
任何建议和指导赞赏...