-->
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: Mapping: How to join 2 tables on multiple columns?
PostPosted: Wed May 09, 2007 10:25 am 
Newbie

Joined: Fri Apr 27, 2007 5:26 am
Posts: 1
Hibernate version: 3.2.3

Mapping documents:

<class name="Alarm"
<id name="alarmId" column="alarm_id">
<generator class="assigned"/>
</id>

<property name="alarmDefinitionId">
<column name="alarm_definition_id" />
</property>

<property name="alarmDefinitionVersion">
<column name="version_id" />
</property>

<join table="alarm_definition">
<key column="alarm_definition_id" property-ref="alarmDefinitionId"/>
<key column="alarmDefinitionVersion" property-ref="version_id"/>
<property name="alarmDefinitionName" column="name"/>
</join>
</class>


Name and version of the database you are using: Oracle 9i

I would like to join a table called alarm with another table called alarm_definition to retrieve a single column from the alarm_definition table called name.

My problem is that the primary key of the alarm_definition table is made up of 2 columns. I need to join the alarm table by both alarm_definition_id and version_id. I cannot find a way to do this. I expected to be able to do something like the join below but the join element can have only one key element and key can have only one column element.

<join table="alarm_definition">
<key column="alarm_definition_id" property-ref="alarmDefinitionId"/>
<key column="alarmDefinitionVersion" property-ref="version_id"/>
<property name="alarmDefinitionName" column="name"/>

</join>

Any help would be appreciated.


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.