b]Hibernate version:[/b] 3.1
Can Hibernate persist a subclass of a persistent class, where the subclass is not explicitly mapped or described to hibernate, but it's superclass is?
We are considering a proxying approach where we manually substitue "smart" subclasses of a persistent class when we send them to a remote (rich) client. When these "smart" subclasses come back, we would need them to be persistable.
Example:
Code:
class A {
String foo;
/* @hibernate.blah.blah */
public String getFoo() {...}
public void setFoo(String s) {...}
}
class SmartA extends A {
String fooID;
A underlyingObject = null;
public String getFoo() {
if (A==null)
retrieveObjectFromServer(fooID)
return A.getFoo();
}
}
We want to replace A with SmartA to avoid sending the whole object graph to the client but if A is set on the client or modified, we want the saving, cascade-dirty checks to all work as normal.
Is this approach sound?