-->
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.  [ 1 post ] 
Author Message
 Post subject: Multiple foreign keys as the primary key
PostPosted: Tue Jul 05, 2005 9:58 am 
Newbie

Joined: Fri Oct 01, 2004 8:36 pm
Posts: 8
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

3.0


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>

<class name="Cinema">
<id name="id" column="id">
<generator class="identity"/>
</id>

<many-to-one name="cinemaGroup"
class="CinemaGroup"
column="cinemagroup_id"
not-null="true"
/>

<many-to-one name="address"
class="Address"
column="address_id"
not-null="true"
cascade="save-update"
/>

<bag name="nearestCinemas" lazy="true">
<key column="id"/>
<one-to-many class="CinemaDistance"/>
</bag>

<property name="name" not-null="true" />
<property name="contactName" />
<property name="telephoneNumber" />
<property name="customerNumber" />
<property name="emailAddress" />
<property name="mapReference" />
<property name="otherCustomerInformation" />
<property name="carParkingId" not-null="true" />
<property name="disabledOptionsId" not-null="true" />
</class>

</hibernate-mapping>


MySQL 4.0

Hi,

I have a schema query. I am trying to model the following in Hibernate: I have a Cinema object (as mapped above). I want to have a look up table that contains two cinema id's (fromCinema and toCinema) and the distance between then (as a float). So for example:

Cinema Table:
id (PK)
name
emailaddress

CinemaDistance Table:
fromId (FK of Cinema.id)
toId (FK of Cinema.id)
distance (float)

I'm not sure how to define the CinemaDistance object in Hibernate. Is this posible?


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

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.