Fixes #1039 on 2.x branch.
Merge pull request #1047 from mdogan/fix/2.x/hibernate

Fixes #1039 on 2.x branch.