昨天面试被问了一个hibernate的问题,一个User类有username,password属性,还有otherInformation等其他属性,username和password映射到一个表,otherInformation等其他属性映射到另一个表,使用User类时不会感觉到是两个表的的存在,如何配置User.mapping.xml文件进行配置??
这叫“Table per subclass”:
[code="xml"]
...
...
[/code]
表2的主键与父表表1的主键是一个一对一的关联。
应该是用subclass继承。
好像不能这么做
应该不行吧,否则进行映射的时候,没法区分到底指向那个数据表了、