226 CHAPTER (Free web hosts) 11 n FILTERING THE RESULTS OF

226 CHAPTER 11 n FILTERING THE RESULTS OF SEARCHES CHAPTER 11 n FILTERING THE RESULTS OF SEARCHES filter would specify that the status column must match a named parameter. You would not need to define the possible values of the status column in the Hibernate mapping document the application can specify those parameters at run time. Although it is certainly possible to write applications with Hibernate that do not use filters, we find them to be an excellent solution to certain types of problems notably security and personalization. Defining Filters Your first step is to define filters in your application s Hibernate mapping documents, using the XML element. These filter definitions must contain the name of the filter and the names and types of any filter parameters. Specify filter parameters with the XML element. Filter parameters are similar to named parameters for HQL queries. Both require a :before the parameter name. Here is an excerpt from a mapping document with a filter called latePaymentFilter defined: Once you have created the filter definitions, you need to attach the filters to class or collection mapping elements. You can attach a single filter to more than one class or collection. To do this, you add a XML element to each class and/or collection. The XML element has two attributes: name and condition. The name references a filter definition (for instance: latePaymentFilter). The condition represents a WHERE clause in HQL. Here s an example: Each XML element must correspond to a element. You may have more than one filter for each filter definition, and each class can have more than one filter. This is a little confusing the extra level of abstraction allows you to define all the filter parameters in one place and then refer to them in the individual filter conditions.
We would like to recommend you tested and proved virtual web hosting services, which you will surely find to be of great quality.

Leave a Reply