After finding some references to this issue in the forum I tried creating a CompositeUserType, but I ran into a snag. My implementation class is locale specific (NLAddress, UKAddress, NLMobile, UKMobile etc).
The country code is stored in the user table. For a CompositeUserType, the returned class would therefore be dependent on the information read from the database. Since it seemed I could probably not get this to work, I resolved to violate the architecture a little.
In stead on making AnAddress and AMobile abstract classes, I made them concrete. Then, I added class="package.AnAddress" and class="package.Amobile" to the relevant hibernate.component reference.
I'm wondering if there is a way to do this without violating architecture principles. Especially, since the documentation suggests that a fine grained object model is the aim, and this seems not an uncommon architecture ;-) I did see some reference in the forum to extending the component class to support inheritance, but judging from the Hibernate 3.0 codebase this was never followed up on. I would have expected more references to this issue on the forums, which only suggests that I might be an idiot. I probably missed the obvious. I'd love to be enlightened.
Kind regards,
Marc
|