To further clarify my problem: the last line of code in my previous comment throws a java.lang.ClassCastException with Hibernate 6