-->
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.  [ 2 posts ] 
Author Message
 Post subject: which mapping shud I use and how..
PostPosted: Fri Oct 21, 2005 3:12 pm 
Beginner
Beginner

Joined: Wed Oct 19, 2005 12:03 pm
Posts: 21
Hi,

I am new to hibernate and needed help on which mapping I shud use.

I have class Vehicle. This class contains an object of type VehicleType.
There can be many vehicles of one particular type. I was using a many-to-one unidirectional mapping between Vehicle and VehicleType with a foreign key in Vehicle mapping to the primary key in Vehicle Type. I was using a field in Vehicle class and in its table called FKey_vtID which was mapped to the primary key of the vehicle. I want to avoid using this extra field which will need to be checked. Vehicle Type class and table have no reference to the Vehicle. Am I using the correct mapping. IF i want to avoid using the foreign key column and still have them mapped. How shud my mapping files look like.

I wud be grateful for any comments.
Thanx
Shefali


Top
 Profile  
 
 Post subject: 2c
PostPosted: Fri Oct 21, 2005 5:53 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
It is correct DB schema that has column in Vehicle table that points to primary key of VehicleType table.

Stick with the design unless vehicle may have several types simultaneously,
in this case you will need 3rd link table (vehicle_to_type_link).

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.