---
title: "类继承映射表"
author: "east_java"
date: "2009-07-19T04:00:17Z"
tags: []
slug: "untitled"
draft: false
lastmod: "2009-07-19T04:00:17Z"
id: 428764
url: "https://japi.iteye.com/blog/428764"
---

hiernate用了很久，，但都是很简单的应用。。
现在水平应该也只是hello world水平。

复杂的映射还是没接触过。

现在碰到一问题。
两个类是继承关系，怎么映射到一张表上。
之前的做法很简单，类就是继承的，父类映射文件没有什么问题。
子类映射文件就是把父类以及子类中的属性全部映射下。

这样做，出现了一个问题，就是在查询父类的时候，把子类也查询出来了。也就是一张表查询了两次。

这个其实叫
Table per class hierarchy
http://www.ntsky.com/docs/java/HibernateGossip/HibernateGossip/InheritanceTablePerClassHierarchy.html
还有Table per subclass
http://www.iteye.com/problems/4615

http://www.cnblogs.com/cxccbv/archive/2009/01/21/1379327.html
http://blog.csdn.net/Java619/archive/2007/06/07/1642871.aspx
http://huoli.iteye.com/blog/300317