-->
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 a component class
PostPosted: Fri Nov 26, 2004 3:55 pm 
Newbie

Joined: Fri Nov 26, 2004 3:08 pm
Posts: 1
I have studied hibernate using this wonderful book. Of course, it does not cover all cases.
I'm trying to put Hibernate in some practice developing a small software for managing skydive dropzones.

I'm having a question mapping a component class inside another class. Let me explain.

I have a class named Aircraft with two String fields (licence and description) and its getters and setters. I have another simple class named AircraftJumpPrice, with two numeric fields (altitude and price).

I want to make an aggregation mapping with this two classes, like this:

Code:
<class name="br.com.noground.entities.Aircraft">
  <id name="id">
    <generator class="increment"/>
  </id>
  <property name="prefix" length="5" not-null="true"/>
  <property name="description" length="50" not-null="true"/>
  <set name="jumpPrices" lazy="true">
    <key column="aircraft"/>
    <composite-element class="br.com.noground.entities.AircraftJumpPrice">
      <property name="altitude" not-null="true"/>
      <property name="amount" not-null="true"/>
    </composite-element>
  </set>
</class>


That is, one aircraft have a set of jump prices, one for each altitude.

My question is: how do I make the property to be unique but only inside a Set? Just like the way I showed above, duplicate jump prices with the same altitude can repeat for the same aircraft. For example:

for the aircraft "NPLEE (Twin Otter)" I have the following prices:
at 13000ft the price is $ 20
at 7000ft the price is $ 10

for the aircraft "NHJSA (Cessna Caravan)" I have the following prices:
at 13000ft the price is $ 19
at 7000ft the price is $ 10

I cannot have the unique constraint to the property "altitude" it wont allow the 13000ft again for the NHJSA aircraft.

Any ideas?


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.