There are situations where you may want to work with a subset of objects, instead of the entire set of objects. In such situations, you may implement appropriate HQL expressions to load the desired objects. This is not a good practice, because you always need to call HQL expressions to load the objects. In our example of an education system application, suppose a requirement indicates that the application must be implemented so that we can configure it to view and use the information for only current students, only those students who have graduated, or only those students older than a specified age.
Hibernate allows us to filter the returned objects at the
Session level. To use filters, follow these three steps: