Thanks for your quick response Max.
Quote:
Just a small comment - there is *no* problem in using polymorpishm with respect to associations in hibernate. The issue you have is about representing NULL, something that is more related to the kind of datamodelling people tend to do and not OO.
When I have modeled -to-zero-or-one or -to-zero-or-n relationships I just want to be able to continue to code like:
Code:
if ( insurancePolicy != null )
insurancePolicy.makeClaim();
else
System.out.println("You crashed into a what?");
Where insurance policy classes are subclasses of an InsurancePolicy class - there could be a whole heap of them all implementing makeClaim in slightly different ways.
Quote:
The users I see having problem with polymorphic associations are mostly those who want to downcast their objects which again is something that is arguable OO.
Yes, well there's real OO (where every character in a string is implemented as an individually instantiated character object - eg., Smalltalk language) and there's practicle, usable OO. And sometimes in practicle, usable OO you need to downcast.
Like when you have implemented methods that, for type safety reasons (detected at compile time, not run time), take a specific subclass as a parameter.
Code:
XyzInsuranceCompany::establishXYZPolicy(XYZPolicy xyzPolicy)
{
}
You can't just pass a reference to the super class (eg., insurancePolicy) to these methods. The compiler won't let you pass the proxy in for this parameter and you won't be able to cast it either.
Quote:
And note, that just because there *can* be a association defined between two objects, doesnt mean it *has* to be physically represented in your object model.
I agree with that. If you have a one-to-one why not just merge the two objects into one... but if you have a one-to-zero-or-one then you can't merge them.
Quote:
In any case, all is possible now with H3.1, so go buy your bigger machines ;)
Kewl! So byte code enhancement is all good and stable in 3.1?