Let's take a look at how to add restrictions, which are equal to the WHERE
clause in SQL.
Let's consider that we have four records in the employee table, as shown in the following tables:
This is the Employee
table:
department |
salary |
firstName |
id |
---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This is the Department
table:
deptName |
id |
---|---|
|
|
|
|
|
|
Now, the scenario is that we want to get only those employees whose salary is greater than 35000
.
The equivalent SQL query to select the above employees is as follows:
SELECT * FROM employee WHERE salary > 35000;
Now, let's look at how to do the same using hibernate.