-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: one-to-one mapping question
PostPosted: Mon Dec 25, 2006 3:25 pm 
Newbie

Joined: Tue Apr 25, 2006 3:41 pm
Posts: 3
Location: Redmond, WA
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>


Top
 Profile  
 
 Post subject: Use Discriminator
PostPosted: Tue Dec 26, 2006 1:03 pm 
Newbie

Joined: Tue Dec 19, 2006 12:19 pm
Posts: 4
Hi,

read about Discriminator,
and watch the Mapping samples.

Take a look that you need some field in the CAR table,
to tell you on which car are you working on

_________________
!!!Sharik!!!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 09, 2007 1:26 pm 
Newbie

Joined: Fri Oct 14, 2005 6:22 am
Posts: 7
I have de same problem that Ramaseshen, have somebody found a solution?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.