O'Reilly logo

Spring Persistence with Hibernate by Ahmad Seddighi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Filters

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:

  1. Define a filter: This step ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required