Hello,
I was playing with Hibernate and noticed that multiple mapping of the same column behaves differently in class and component. If I create multiple mappings under class and set insert and update to false (see "CITY MAPPING 1"), everything works fine. But if I do the same thing under component (see "CITY MAPPING 2"), "Repeated column" is reported. Here are my mappings:
Code:
<hibernate-mapping>
<class name="hibernate.City" table="CITY">
<id name="ID">
<generator class="native"/>
</id>
<property name="name"/>
</class>
<class name="hibernate.Person" table="person">
<id name="ID">
<generator class="native"/>
</id>
<property name="name"/>
<property name="street" insert="false" update="false"/>
<property name="houseNo" column="HOUSE_NO" insert="false" update="false"/>
<!-- CITY MAPPING 1 -->
<property name="cityID" column="city_id" insert="false" update="false"/>
<property name="cityID2" column="city_id" insert="false" update="false"/>
<many-to-one name="city" column="city_id" insert="false" update="false"/>
<component name="address">
<parent name="person"/>
<property name="street" insert="false"/>
<property name="houseNo" column="HOUSE_NO"/>
<!-- CITY MAPPING 2 -->
<property name="cityID" column="city_id" insert="false" update="false"/>
<property name="cityID2" column="city_id" insert="false" update="false"/>
<many-to-one name="city" column="city_id" insert="false" update="false"/>
</component>
</class>
</hibernate-mapping>