on 09-06-2016 6:33 PM
Can we (and how) order by date, putting the dates with NULL last, with flexible search ?
We want to make with via the FlexibleSearch and to avoid specific database vendor solution, since we work with MySQl for dev machines and Oracle for production and test machine / env
Meaning I would avoid such solutions as:
SELECT {pk} FROM {Address} ORDER BY {address.lastUsed} DESC NULLS LAST
Simply because, this will not work for dev base machines, where MySQL is
In case someone faced it: a solution for such a case could be creating of a java comparator and simply sorting the instances. As per the example above:
addresses.stream().sorted(new LastUsedAddressDataComparator()).collect(Collectors.toList());
where LastUsedAddressDataComparator is the comparator makes compares 2 instances of Address
Of course, such a solutions is a nice one, for not too may instances getting sorted, because first we are getting all instances from the DB and then we are storing them, instead of directly getting sorted with the DB query. But it's fine for a reasonable number of instances ("reasonable" - depending on the context of usage of course)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.