CHAPTER 12 Modifying objects efficiently use aCategory.getItems() and

CHAPTER 12 Modifying objects efficiently use aCategory.getItems() and navigate to these objects, all Item instances would be visible. You solve this problem with a dynamic filter. Defining a data filter A dynamic data filter is defined with a global unique name, in mapping metadata. You can add this global filter definition in any XML mapping file you like, as long as it s inside a element: This filter is named limitItemsByUserRankand accepts one runtime argument of type int. You can put the equivalent @org.hibernate.annotations.FilterDef annotation on any class you like (or into package metadata); it has no effect on the behavior of that class: @org.hibernate.annotations.FilterDef( name=”limitItemsByUserRank”, parameters = { @org.hibernate.annotations.ParamDef( name = “currentUserRank”, type = “int” ) } ) The filter is inactive now; nothing (except maybe the name) indicates that it s supposed to apply to Item objects. You have to apply and implement the filter on the classes or collections you want to filter. Applying and implementing the filter You want to apply the defined filter on the Item class so that no items are visible if the logged-in user doesn t have the necessary rank: MySQL5 Web Hosting services.

Leave a Reply