The pull request https://github.com/hibernate/hibernate-orm/pull/935 contains a test case and a bug fix suggestion.