File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Hibernate: confusion how to include seperate attribute in many-to-many mapping file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate: confusion how to include seperate attribute in many-to-many mapping file" Watch "Hibernate: confusion how to include seperate attribute in many-to-many mapping file" New topic
Author

Hibernate: confusion how to include seperate attribute in many-to-many mapping file

Maya Dolas
Greenhorn

Joined: Jul 04, 2007
Posts: 26
Hello,

I am stuck in the following scenario

TABLES: Vehicle(vid, vdesc, basePrice, <Set>vFeatures),
Feature(fid, fcode, fprice),
VehicleFeatures(vid, fid, featurePrice)

Here I have associated Vechicle-Feature by many-to-many relationship. I am also storing the price of a particular feature for a particular vehicle in VehicleFeatures table. I would like to know is this correct way to map association between Vehicle and Feature or should I use One-Many relationship? If the association is correct how do I include it in mapping file of VehicleFeatures.hbm.xml. The problem is what should I use in the <id> tag of this mapping file. Below are the mapping files that I have created

Vehicle.hbm.xml


Feature.hbm.xml


VehicleFeatures.hbm.xml (My problem is how do i write this file, what should be specified in the <ID> tag)


Since I need an explicit mapping for VehicleFeatures, so haven't used many-to-many between Vehicle and Feature.


<b><i>Maya</i></b>
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

Since the central table has a field in it, the central table, which we usually think of as a join table, isn't really a true join table in the pure sense of the word.

One approach that works is to divide the many to many into two one to many relationships pointing to the join table.

-Cameron McKenzie
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate: confusion how to include seperate attribute in many-to-many mapping file
 
Similar Threads
Retereive data by ORDER BY
Item - Bid Unidirectional PROBLEM !!!
How to specify relationship in mapping file
hibernate migration
MappingException: Could not read mappings from resource