Product Version: NetBeans IDE 6.5 (Build 200811100001)
Java: 1.6.0_10; Java HotSpot(TM) Client VM 11.0-b15
System: Windows XP version 5.1 running on x86; Cp1252; nl_NL (nb)
Framework: JavaServer facesDue to limitation of the usage of parameters in named queries I have been forced to do operations on the output list that might have been possible in a named query.
The approach I have taken works, but is too slow when the number of records increases (200 is fine, 2000 not anymore).
I hope anyone can give me some advice, I did highlight my specific questions.
I have to do four steps:
1. Get a list with a specific feature
2. Apply user specified filters (if any) on that list
3. Hide (part of) records that specific users are not allowed to see
4. Sort the result via one of 4 options the user can pick
I can only do the first step via a named query.
The reason the filter does not work is that the filter is applied on a linked table twice. Example (person is nicely linked):
Code:
Select Rol r Where
r.person.name = :name AND
r.person.city = :city
This runs into a nullpointer, which is explained here:
http://opensource.atlassian.com/project ... e/HHH-2159 QUESTION: The patch on the above page, can I apply that myself? If so, how?Then I tried to do the above in two steps:
Code:
Step 1: Select Person p WHERE name=:name and city=:city
Step 2: Select Rol r WHERE person in (:person)
The second step gives a compilation error. I cannot use parameters like this.
QUESTION: Is there another syntax for what I am trying to do in step 2?I now do step 2 by running though the List<Rol> and using string compares (startWith actually). This is of course, slow, and profit any index in the database.
Step 3 does not give me any problems. If I could do step 2 with a NamedQuery, I could probably put step 3 in this as well. Step 3 has to be done before step 4, because, if a user has no rights to see an address, sorting on zipcode might give away something. See this small example:
For sorting I tried to specify the sorting column(s) via a parameter. (Select Rol r Order by :order). This also was not an acceptable place for a parameter. Since the number of sorting methods is limited (4) I created 4 named queries and called the one I needed. This worked fine, but that was before I was putting in the filter.
Now I use Collections.sort with a sorting function as parameter. I think that works just as fine as sorting in the Namedquery. But I need to test that more.
One of the reasons I would like to use the NamedQuery variant, is that I could make use of the sublist function. That function should also speed up larger lists, by displaying them one page at a time. However, I do want to have the sorting over the whole list, not only over the displayed items.
QUESTION: Can I use parametered search in a NamedQuery?Finally, if the plan to do this via NamedQueries is not going to work. Are there other tips to filter a List?
Thanks if you have read this far!