i'm sure somebody following the top-design must have faced this problem during the generation of hibernate mapping xmls from pojo code marked with xdoclet tags.
in the Employee class i mark getName() as @hibernate.component. i mark all the getters in the Name class as @hibernate.property. when i give this an <hibernatedoclet> spin, i'll end up with a generated xml something like this.
Code:
<class name="Employee" table="employees">
<id name="id">
<generator class="sequence">
<param name="sequence">employee_id_seq</param>
</generator>
</id>
<property name="taxfileNumber"/>
<component name="name" class="Name">
<property name="firstName"/>
<property name="initial"/>
<property name="lastName"/>
</component>
</class>
now if have another getter in Employee let's say getMotherName() which also returns a Name object. so i mark that with @hibernate.component as well.
now we get:
Code:
<class name="Employee" table="employees">
<id name="id">
<generator class="sequence">
<param name="sequence">employee_id_seq</param>
</generator>
</id>
<property name="taxfileNumber"/>
<component name="name" class="Name">
<property name="firstName"/>
<property name="initial"/>
<property name="lastName"/>
</component>
<component name="motherName" class="Name">
<property name="firstName"/>
<property name="initial"/>
<property name="lastName"/>
</component>
</class>
not surprisingly this causes causes :
[STDERR] net.sf.hibernate.MappingException: Repeated column in mapping for class com.alterpoint.aof.objects.platform.impl.ManagedElementImpl should be mapped with insert="false" update="false": firstName
does there seem to be a major flaw in my usage (though generated). how do i map multiple fields to the same <component>.
thanks
ravi