I am having table CAR having one-to-one relation with 3 other tables HONDA, TOYOTA and MARUTI. The primary key for Honda, Toyota and Maruti is shared with Car. (i.e, When I save Honda, i first save car and then Honda with the same primary key).When i do honda.getCar(), it executes a query joining Honda, car, Toyota and Maruti. I don't want it to join with other car types (Honda and Maruti). How do i restrict the query not to inner join with other car types. I am using Hibernate 3.1.
How do i make my query not to query other one-to-one mapped classes?
The mapping for CAR class:
<hibernate-mapping>
<class name="com.services.dao.Car" table="CAR">
<id name="caridentity" type="long">
<column name="CAR_IDENTITY" precision="10" scale="0" />
<generator class="sequence">
<param name="sequence">SEQ_CAR</param>
</generator>
</id>
<one-to-one name="honda" class="com.services.dao.Honda" cascade="all" />
<one-to-one name="toyota" class="com.services.dao.Toyota" cascade="all" />
<one-to-one name="maruti" class="com.services.dao.Maruti" cascade="all" />
</class>
</hibernate-mapping>
The mapping for Honda class:
<hibernate-mapping>
<class name="com.services.dao.Honda" table="HONDA">
<id name="hondaidentity" type="long">
<column name="HONDA_NEIDIDENTITY" precision="10" scale="0" />
<generator class="foreign" >
<param name="property">car</param>
</generator>
</id>
<one-to-one name="car" class="com.services.dao.Car" constrained="true" />
</class>
</hibernate-mapping>
|