Given the following snippet:
List<MyEntity> entities = query.list();
for(MyEntity entity : entities) {
for (OtherEntity relatedEntity : entity.getRelationshipEntities() ) {
if (relatedEntity instanceof ConcreteEntityOne) { }
}
}
That will need to be changed to something like:
To avoid such thing being spread all over the place, then the only other way would be to have a hibernate listener that will unproxy the loaded entity and it will be in a single place… So, if I’m initializing a collection of a polymorphic entity, I’ll need to unproxy its elements. |