I have tried couple of different options. See attached patch file, especially the special LimitHandler implementation.
At this point, the only real options I see are:
continue applying paging, ordering, etc to the SQL; but apply locks individually on the resulting rows/objects. This would be difficult with scalar queries.
continue applying locking, ordering, etc to the SQL; but for paging, we would have to use ResultSet#absolute() + seeking through ResultSet from that position. This would cause rows outside the "current page" to be locked.
I have tried couple of different options. See attached patch file, especially the special LimitHandler implementation.
At this point, the only real options I see are: