Hibernate version: 3
Hello. How can I session.load() a concrete subclass if I know the ID and not the concrete subclass? I use Table per subclass mapping.
I have 3 classes: Widget (abstract superclass) and subclasses WidgetPicture and WidgetLine.
Code:
Widget widget = (Widget) session.load(Widget.class, id);
// now widget contains proxy class and it can't be retyped to a concrete subclass
// this (ugly) hack will retrieve the correct subclass:
Widget widget = (Widget) session.load(session.getEntityName(widget), id);
The second line moreover generates a warning:
Code:
WARN PersistenceContext - Narrowing proxy to class com.kovine.kfe.dao.WidgetPicture - this operation breaks ==
So, what I need is to load a concrete subclass but I know only the ID, not the concrete subtype. I've found in the hibernate forums similar problems, but not one solving this issue.
Gurus, please help me and you'll get to the heaven :)
Martin