一個User類有username,password屬性,還有otherInformation等其他屬性,username和password映射到一個表,otherInformation等其他屬性映射到另一個表,使用User類時不會感覺到是兩個表的的存在,如何配置User.mapping.xml文件進行配置?
這叫“Table per subclass”:
<class name="Base" table="表1">
<id name="id" type="long" column="BASE_ID">
<generator class="native"/>
</id>
<property name="username" column="username"/>
<property name="password" column="password"/>
...
<joined-subclass name="User" table="表2">
<key column="BASE_ID"/>
<property name="otherInformation" column="otherInformation"/>
...
</joined-subclass>
</class>
原:http://www.iteye.com/problems/4615