Hibernate如何一个类映射两个表

一个User类有username,password属性,还有 otherInformation等其他属性,username和password映射到一个表,otherInformation等其他属性映射到另一 个表,使用User类时不会感觉到是两个表的的存在,如何配置User.mapping.xml文件进行配置??

这叫“Table per subclass”:

Xml代码  收藏代码

    <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>
上一篇:Java2_Java泛型


下一篇:Spring 3 MVC: Themes In Spring-Tutorial With Example---reference