JPA - select with join - how to make two related tables -


i have 2 tables relacionship id_employee.

 ---------------------------       --------------------------- table employee                      table timesheet ---------------------------       --------------------------- id_employee                        id_time name_employee                      date_entry ---------------------------        quant_hour                                    id_employee                                   --------------------------- 

i need select returns records table employe , hours in existing related table timesheet. employees not have hours recorded in timesheet table should appear in list because registered in employee table.

what jpql query ?

class employee

@entity public class employee {  @id @generatedvalue private long id_employee; private string name_employee ;      //gets , sets } 

class timesheet

@entity public class timesheet {  @id @generatedvalue private long id_time; private double quant_hour;     private date date_entry; @manytoone private employee employee;        //gets , sets } 

provided both tables mapped correctly,the employee entity have attribute (or collection) of type timesheet entity, therefore, need list of employees:

select e employee e 

jpa automatically retrieves timesheet (or list of timesheets) when want read employee entity.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -