From all indications within the hibernate documentation it appears that it supports bean property type mappings, but when I attempt to use a nested composite identifier I can't figure out how to accomplish this. Here is an example of a mapping that I would like to be able to create.
Code:
<class name="eg.Foo" table"FOOS">
<composite-id name="compId" class="eg.FooCompositeID">
<key-property name="test.string"/>
<key-property name="test.short"/>
</composite-id>
</class>
I have searched high and low within the hibernate documentation on how to accomplish such a task and have been unable to figure out how to do so. I realize that one of my problems is that I am using a composite identity, which Hibernate's philosophy is generally against. :) But unfortunately the decision to use a composite identifier has already been made.
A solution to this problem is rather simple due to the good design of creating a reflection helper class. Here is a sample of a change to the ReflectHelper class that would make this possible.
Code:
private static Method getterMethod(Class theClass, String propertyName) {
return
org.apache.commons.beanutils.PropertyUtils.getPropertyDescriptor(java.lang.Object bean, java.lang.String name) .getReadMethod();
}
Obviously this is pseudo code, but it displays the utilization of the PropertyUtils class(part of the Jakarta Commons) that can return simple, nested, indexed, mapped, and combined type of properties from a bean.
Please let me know if a change like this would be necessary / possible, or if there is another solution to this type of an example besides using a CompositeUserType. I find that the CompositeUserType does not offer enough dynamic flexibility when used on a large scale basis. Everything within the class must be hard coded.
Thanks in advance,
Dan