Adam Heath-2 wrote: > >> If we can provide a generic solution, this will be a good add-on. Please >> share your views. > > Is it possible that some jdbc metadata parameter can specify whether > the database supports this? >
The patch contains a parameter: + use-order-by-nulls="true"> for this purpose. For the databases listed it will generate a database native "NULLS FIRST/LAST" statement as part of the order by clause. For the other databases (the ones where this property is not set or is set to "false") it will generate a case: + if ((nullsFirst != null) && (!datasourceInfo.useOrderByNulls)) { + sb.append("CASE WHEN "); + getValue().addSqlValue(sb, modelEntity, null, includeTablenamePrefix, datasourceInfo); + sb.append(" IS NULL THEN "); + sb.append(nullsFirst ? "0" : "1"); + sb.append(" ELSE "); + sb.append(nullsFirst ? "1" : "0"); + sb.append(" END, "); + } + It should be noted that this generation only occurs if the "nulls" is explicitly specified on the order-by clause. I thought about always generating this snippet to support a "default sorting behaviour" across all databases, but I did not want to alter existing sql statements without a discussion on that. So with this patch one can explicitly specify how they want nulls sorted and it should work for all databases. -- View this message in context: http://ofbiz.135035.n4.nabble.com/Bug-Not-Null-Values-are-at-top-when-fetching-list-from-database-in-Release-9-04-tp2062221p2134052.html Sent from the OFBiz - Dev mailing list archive at Nabble.com.