Backport for #3882, honor query cache config
Clean forgotten lines
Rebase
Merge pull request #4171 from emrahkocaman/fix/maintenance-3.x/hibernate

Backport for #3882, honor query cache config