Look under the select clause:
http://www.hibernate.org/hib_docs/refer ... l-examples
- e.g.: select cat.name from eg.DomesticCat cat
You can do the same for your class A, and retreive only the attributes that are part of class A. That way hibernate will not link all the tables to establish which class this object is really of.
Wanted solution introduces conflict with Hibernate's principle - you would eventually have two objects of different class instance with same id - which one is right?
Probably the only solution is that you make a new class DefaultA which is a superclass of A (maybe A then becomes empty class). Then set DefaultA's polymorphism to 'explicit'. When trying to load only A's you will actually load DeafultA's. The rest of B, C, ... will have a normal expected polymorphic behaviour.
>>Explicit polymorphism is useful when two different classes are mapped to the same table (this allows a "lightweight" class that contains a subset of the table columns).
That will ofcourse requre new mapping for DeafultA (duplicated only A's).
And query then changes to 'from DefaultA where ...'.
Or you can run hbm2java on below mapping (get duplicated class DefaultA and A).
Here what your mapping should look like:
<hibernate-mapping>
<class
name="eg.DefaultA"
table="aaa"
dynamic-update="false"
dynamic-insert="false"
polymorphism="explicit"
>
<id
name="id"
column="aaa_id"
type="int"
unsaved-value="0"
>
<generator class="native">
</generator>
</id>
<property
name="ident"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="ident"
length="127"
not-null="true"
/>
</class>
<class
name="eg.A"
table="aaa"
dynamic-update="false"
dynamic-insert="false"
>
<id
name="id"
column="aaa_id"
type="int"
unsaved-value="0"
>
<generator class="native">
</generator>
</id>
<property
name="ident"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="ident"
length="127"
not-null="true"
/>
<joined-subclass
name="B"
table="bbb"
dynamic-update="false"
dynamic-insert="false"
>
<key
column="bbb_id"
/>
<property
name="protocolId"
type="java.lang.Integer"
update="true"
insert="true"
access="property"
column="protocol_id"
length="10"
/>
</joined-subclass>
</class>
</hibernate-mapping>