See pull request https://github.com/hibernate/hibernate-orm/pull/1357 for proposed fix and a test case.