cancel
Showing results for 
Search instead for 
Did you mean: 

Can we (and how) order by date, putting the dates with NULL last, with flexible search ?

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

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)