0
我有id_employee与relacionship的两张表。JPA - 与加入选择 - 如何制作两个相关的表
--------------------------- --------------------------- table employee table timesheet --------------------------- --------------------------- id_employee id_time name_employee date_entry --------------------------- quant_hour id_employee ---------------------------
我需要做一个选择,返回雇员表中的所有记录和现有相关表格时间表中的小时数。某些员工在时间表中没有记录小时数,但应该出现在列表中,因为他们已在员工表中注册。
什么JPQL查询这个?
类Employee
@Entity
public class Employee {
@Id @GeneratedValue
private Long id_employee;
private String name_employee ;
//GETS and SETS
}
类的TimeSheet
@Entity
public class Timesheet {
@Id @GeneratedValue
private Long id_time;
private Double quant_hour;
private Date date_entry;
@ManyToOne
private Employee employee;
//GETS and SETS
}
由于JPQL在entites上操作,因此它取决于您的实体而不是您的表。请发布雇员和时间表班级代码(只有属性和注释,而不是gettes/setters) – kostja 2013-05-02 15:53:54
更新请求...包括类! – 2013-05-02 16:53:54