HI,
I have check around in the forum and in the hibernate doc, and I didn't found a simple example of retrieving a record with a composite key.
I have this mapping:
Code:
<class name="ExchangeRate"
table="ExchangeRate"
mutable="false">
<composite-id name="id" class="ExchangeRateId">
<key-property name="Currency" type="TrimmedString">
<column name="Currency" scale="3" precision="0" not-null="true" sql-type="char" />
</key-property>
<key-property name="RateDate" type="Numeric8DigitToDateFormat">
<column name="RateDate" scale="8" precision="0" not-null="true" sql-type="numeric" />
</key-property>
</composite-id>
<property name="Rate" type="java.math.BigDecimal">
<column name="Rate" scale="13" precision="7" not-null="true" sql-type="decimal" />
</property>
(-- more properties here... --)
</class>
I would like to know what is the "one liner code" (simpliest code) for my DAO method "getExchangeRateByIDs(currency, date)".
I need to use it for retrieving a record by the composite primary key. Can I use the session.load()? but I dont have the "Primary key" of the composite-key class (ExchangeRateId).
Should I use a Criteria? Could I have an exemple please? I would prefer not to use HQL here...
Thanks all
Etienne
Montreal