Test case for https://hibernate.atlassian.net/browse/HHH-8581