CHAPTER 12 Modifying objects efficiently List- filteredItems = session.createQuery(”from Item”).list(); List
- filteredItems = session.createCriteria(Item.class).list(); Two object-retrieval methods are not filtered: retrieval by identifier and navigational access to Item instances (such as from a Category with aCategory.get- Items()). Retrieval by identifier can t be restricted with a dynamic data filter. It s also conceptually wrong: If you know the identifier of an Item, why shouldn t you be allowed to see it? The solution is to filter the identifiers that is, not expose identifiers that are restricted in the first place. Similar reasoning applies to filtering of many-to-one or one-to-one associations. If a many-to-one association was filtered (for example, by returning null if you call anItem.getSeller()), the multiplicity of the association would change! This is also conceptually wrong and not the intent of filters. You can solve the second issue, navigational access, by applying the same filter on a collection. Filtering collections So far, calling aCategory.getItems() returns all Item instances that are referenced by that Category. This can be restricted with a filter applied to a collection: … Jboss Web Hosting services.
This entry was posted
on Saturday, December 29th, 2007 at 9:05 pm and is filed under j2ee.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.