OK, but is it possible to control the result list attributes/elements returned from a query using Criteria?
It seems like you can only specify the "FROM" and onward of a respective SQL query with Criteria...but not the SELECT aspect.
Right now, since my response presentation in JSPs are dependent on what fields the user wants to view, I am traversing through the relative Class object's fields and displaying only those that are considered "checked for viewing". The overhead is not tremendous, since the classes are small, but I'm sure there is a cleaner way to do it! ;)
I like the idea behind the Criteria, and may indeed need to utilize the dynamic features in the future...the only pitfall I'm finding is the lack of "SELECT" ability to limit the returned elements, but that may be against the design principle of OR mapping to the Class via Criteria.
I don't want to get too detailed, nor bore you with my application issues...but essentially what I am doing now is as follows (read if you'd like):
- Maintaining a HashMap of user desired view fields based on what is selected in the form.
- Maintaining a HashMap of user defined select fields and values based on what is selected in the form.
- Maintaining a HashMap of user desired matching (Partial or Exact) or the above selected fields.
Based on the 2nd and 3rd collections, I define the Criteria.
The 1st collection determines what is displayed at the presentation layer.
I'm trying to determine how best to encapsulate the desired data, which differs (potentially) from the actual selection criteria fields.
As mentioned above, I traverse through the 1st HashMap of desired view fields for each row of the returns Object Mapping result list based on the Criteria driven query (so it is two JSTL embedded forEach loops...which results in duplication, overhead, and essentially undesireable code from my perspective, although it works great and is still fast (classes are relatively small).
So that's the skinny, sorry for the novel...but any recommendations you can provide would be greatly appreciated!
Thanks again
|