Revert "Revert "GRAILS-11687 hibernate4: fix hibernate.flush.mode setting doesn't work outside OSIV session""

This reverts commit 1532ba21529555983d34c600fb91065577910438.
Revert "Revert "GRAILS-11687 hibernate3: fix hibernate.flush.mode setting doesn't work outside OSIV session""

This reverts commit 7a3c7ea724209b134e85fa109a8814c46273805f.