Hibernate version: 3.x
Hello
Is it a good idea to use an UserType as a decorator around the returnedClass ?
For example, I have both Text and Image classes, extending a base Item class. I want to be able to make these two classes "linkable" in my web application, that is, I have an Link class extending Item which takes Text or Image in its constructor, and has setUrl/getUrl property accessors.
Does it make sense to use the following mapping for my Link class ? :
<property name="wrapped">
<type name="UrlUserType">
<param name="decorated">Item</param>
</type>
</property>
where UrlUserType uses accessors of Text or Image in nullSafeSet/nullSafeGet to alter their properties whenever they are wrapped in a Link : for example :
Link link = new Link();
Text text = new Text("full text");
link.setWrapped(text); // here, UrlUserType nullSafeGet would do text.setBody("click here to see full text");
thanks,
haki
|