Data filtering and interception a restriction (Free web hosting services) on collections;

Data filtering and interception a restriction on collections; if you iterate through the Item objects in a Category, you ll see all of them. One possible solution for this problem uses database views. SQL doesn t standardize dynamic views views that can be restricted and moved at runtime with some parameter (the currently logged-in user, a time period, and so on). Few databases offer more flexible view options, and if they re available, they re pricey and/or complex (Oracle offers a Virtual Private Database addition, for example). Hibernate provides an alternative to dynamic database views: data filters with dynamic parameterization at runtime. We ll look at the use cases and application of data filters in the following sections. Another common issue in database applications is crosscutting concerns that require knowledge of the data that is stored or loaded. For example, imagine that you have to write an audit log of every data modification in your application. Hibernate offers an org.hibernate.Interceptor interface that allows you to hook into the internal processing of Hibernate and execute side effects such as audit logging. You can do much more with interception, and we ll show you a few tricks after we ve completed our discussion of data filters. The Hibernate core is based on an event/listener model, a result of the last refactoring of the internals. If an object must be loaded, for example, a Load- Event is fired. The Hibernate core is implemented as default listeners for such events, and this system has public interfaces that let you plug in your own listeners if you like. The event system offers complete customization of any imaginable operation that happens inside Hibernate, and should be considered a more powerful alternative to interception we ll show you how to write a custom listener and handle events yourself. Let s first apply dynamic data filtering in a unit of work. 12.3.1 Dynamic data filters The first use case for dynamic data filtering is related to data security. A User in CaveatEmptor has a ranking property. Now assume that users can only bid on items that are offered by other users with an equal or lower rank. In business terms, you have several groups of users that are defined by an arbitrary rank (a number), and users can trade only within their group. You can implement this with complex queries. For example, let s say you want to show all the Item objects in a Category, but only those items that are sold by users in the same group (with an equal or lower rank than the logged-in user). You d write an HQL or Criteria query to retrieve these items. However, if you
You need excellent and relaible webhost company to host your web applications? Then pay a visit to Inexpensive Web Hosting services.

Leave a Reply