Hibernate如何一个类映射两个表
生活随笔
收集整理的這篇文章主要介紹了
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>?
轉載于:https://www.cnblogs.com/lyunyu/p/4974263.html
總結
以上是生活随笔為你收集整理的Hibernate如何一个类映射两个表的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql 禁用密码规则校验
- 下一篇: 在VS中MFC、ATL与WIN32有什么