-
1. Re: How to make findAll() return a sorted collection
haytona Oct 25, 2001 4:40 PM (in response to mack_ng)This seems to work for me. Although I don't know why I need to specify the query line but like you, it doesn't seem to work without it.
findAll
id like "%"
lastName, firstName
<read-ahead>true</read-ahead> -
2. Re: How to make findAll() return a sorted collection
haytona Oct 25, 2001 4:41 PM (in response to mack_ng)> findAll
If its not just a type then the above line would cause problems. ;) -
3. Re: How to make findAll() return a sorted collection
mack_ng Oct 26, 2001 4:57 AM (in response to mack_ng)Hi,
It doesn't seem to work for my case, but there is a difference in the order (Although not sorted). For example for list of 10 items, sometimes 5 of them are sorted, the rest are not. WEIRD.
Anyway, thanks for your guides, I really appreciate that.
Anyone else can help me? Thanks in advance...
Mack -
4. Re: How to make findAll() return a sorted collection
fbiaggi Oct 26, 2001 12:52 PM (in response to mack_ng)Hi,
change:
to
1 = 1
than it will work.
Ciao. -
5. Re: How to make findAll() return a sorted collection
danch1 Oct 26, 2001 3:40 PM (in response to mack_ng)There are some issues with the 2.4.x versions that might make JBoss ignore your sort parameter. The workaround is to use a different name and specify the dummy where clause (1 = 1). I'll get a fix in soon.
-
6. Re: How to make findAll() return a sorted collection
mack_ng Oct 28, 2001 9:45 PM (in response to mack_ng)Hi all,
I have tried to change the query to a dummy one (1 = 1), but the result is still an unsorted list. May I know what you meant by using a different name?
I don't know what is wrong with my program and JBoss, anyway, here I include a code snippet which attempts to list the the collection returned by the entity bean:
Collection collection = customerHome.findAll();
ArrayList arrayList = new ArrayList();
Iterator iterator = collection.iterator();
while(iterator.hasNext())
{ Customer customer = (Customer)iterator.next();
CustomerData customerData = customer.getCustomer();
arrayList.add(customerData);
}
return arrayList;
Where CustomerData is the encapsulating class for all customer fields.
And my finder declaration:
findAll
1 = 1
custCode ASC
<read-ahead>true</read-ahead>
Once again, thanks for everyone's suggestions. I hope that someone will try to see the code above, and if I have done something wrong, I will be grateful if being guided on this issue.
Thanks,
Mack -
7. Re: How to make findAll() return a sorted collection
fbiaggi Oct 29, 2001 2:20 AM (in response to mack_ng)We have a lot of these query's and works fine.
Try to remove the ASC to see if something changes.
In addition you could install P6Spy (very simple) to look at the generated SQL statements.
Ciao. -
8. Re: How to make findAll() return a sorted collection
mack_ng Oct 29, 2001 4:08 AM (in response to mack_ng)Hi,
Feel a little bit awkward of keeping all of you busy solving my problem. Thanks. However, no matter how I tried in accordance with what you said, my program still doesn't work as I expect.
I have installed the P6Spy to trace the SQL call, and I found out that no matter how I changed the finder setting, the SQL Statement is still the simple SELECT statement (Log snippet below)
1004344134753|SELECT Salesman.SlsmanCode,Salesman.SlsmanAddr3,Salesman.SlsmanAddr2,Salesman.SlsmanName,Salesman.SlsmanAddr1,Salesman.Version,Salesman.SlsmanContact,Salesman.SlsmanOprType,Salesman.SlsmanVanCode,Salesman.SlsmanAddr4 FROM Salesman |SELECT Salesman.SlsmanCode,Salesman.SlsmanAddr3,Salesman.SlsmanAddr2,Salesman.SlsmanName,Salesman.SlsmanAddr1,Salesman.Version,Salesman.SlsmanContact,Salesman.SlsmanOprType,Salesman.SlsmanVanCode,Salesman.SlsmanAddr4 FROM Salesman
It seems that my JBoss won't follow the setting....!!! Any more helps or suggestions...???
JBoss Version: 2.4.1
Tomcat Version: 3.2.3
Thanks,
Mack -
9. Re: How to make findAll() return a sorted collection
fbiaggi Oct 29, 2001 10:52 AM (in response to mack_ng)My nhe next suggestion mybe to create a new findAll (finAllSorted)and see if it works...
Ciao. -
10. Re: How to make findAll() return a sorted collection
mack_ng Oct 29, 2001 9:03 PM (in response to mack_ng)Hi,
I finally make my program work after following your suggestion by defining a custom findAll (for example, findAllSorted). Anyway, I just feel weird how come some of you have successfully overriden the findAll method and made it work, but mine will never succeed... Anyway, thanks to all of you for your precious comments and suggestions.
Mack