1. A method of constructing a relational database query from a query expressed in terms of entities in an inheritance hierarchy, comprising: creating an initial tree having nodes corresponding to classes in the inheritance hierarchy; grouping entities in the initial tree into entity groups, to obtain an entity group tree, having nodes based on a mapping of the entities to tables in a relational database; and generating a query statement for nodes in the entity group tree.