java - JPA left join to find unused entries -


I'm sure I'm stupid but I can not seem to know ...

There are two tables:

Department (made, name) employee (EID, first, last, done)

They have related institutions which enter department and staff in JPA management The employee has a departmental field, the department does not maintain the employee list. What I have to do, though, is getting all those departments who do not have any employees using plain old SQL It is easy to connect with one left:

  SELECT d * As Dffter, join the department as e-DIDID = EDID, where eDID is the tap  

How do I translate this query into JPQ? Can i For example, the example I have found for JPQLL passes through another way. for example.

  Select from the employee and add e-mail to e.departmert d  

while something else like

  Select D from Departments De Lieut Job D. Line Where eDepartment is faucet  

But the department does not have a reference for its employees (in my application it is clearly not to the departments and employees). Is it also possible in JPQL?

To do what you are trying to do, you will need to setup mapping from the departments -> Employees (using your example organizations) you can use the mapped attribute, which is based on your schema, like

  @Entity Class Department {... @OneToMany (mapped = = "Employee") collection & lt; Employee & gt; GetEmployees () {....} ...}  

This will allow you to run something like this:

  select from D. D. WHERE d Your employee should have any kind of results.  

Without changing your mapping, you want to be able to run some query to get the results:

  Select from the department d where Is not the first (select the employee and where e.department = d)  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -