Why not add randomization for choosing map class
createMap() is but a trifle to facilitate testing. Personally I think randomizing on various Map impl's here is confusing and it would not be intuitive why it was done. What is important is the order of the fields being sent to the MockDataSource. In this case, there are 2 fields: "id" and "desc". Having some rows put "id" first and the others put "desc" first is adequate to test all the possible variants. I also think it is a good idea to always use a Map that preserves order because when writing these tests, it is not intuitive (for me anyhow) that the Map you're creating is going to iterate in an order different than the one you specify. That is why I changed the Abstract class to always use a LinkedHashMap.
"assuming that first column is a primary key" is a really user-"hostile" feature.
I didn't investigate whether this is just a function of the test or if DIH "in real life" behaves this way. In any case, if this is truly a DIH feature, I wouldn't consider it hostile. The primary key comes first most of the time. In any case, I wanted to solve the bug that this JIRA issue address and no more. If we have questions about default behaviors and want to change how the features work that is probably left to a separate non-"bug" issue.
test methods names withWhereClause() and withKeyAndLookup() at TestCachedSqlEntityProcessor should be swapped each other.
I think you're right, but then again I didn't write these tests, so I'm not sure why they were named this way. Also, changing the names is not directly related to fixing the bug here. Personally, I would love to see the DIH tests get revamped someday so you could just glance through them and understand what they do and how.
In any case, now that I understand the bug and how to fix it, I would rather create a lean patch that someone can quickly evaluate and commit. If we add bloat or make it hard for a committer to understand it might just languish and remain unfixed for a long time.