Mapping question from newbee,
I have the following interest rate table (note: a tier is associated with a min balance);
COMPANY TIER EFFECTIVE_DATE THROUGH_DATE INTEREST_RATE YIELD
902 1 7/9/2007 7/15/2007 0.00 0.00
902 2 7/9/2007 7/15/2007 1.82 0.00
902 3 7/9/2007 7/15/2007 2.32 0.00
902 1 7/16/2007 7/22/2007 0.00 0.00
902 2 7/16/2007 7/22/2007 1.82 0.00
902 3 7/16/2007 7/22/2007 2.32 0.00
902 1 7/23/2007 7/29/2007 0.00 0.00
902 2 7/23/2007 7/29/2007 1.82 0.00
902 3 7/23/2007 7/29/2007 2.32 0.00
I have successfully mapped an InterrestRate class to an individual row with this mapping;
Code:
<class name="InterestRate" table="INTEREST_TIERS" >
<composite-id>
<key-property name="companyId" column="COMPANY" />
<key-property name="tier" column="TIER" />
<key-property name="effectiveDate" column="EFFECTIVE_DATE" type="date"/>
</composite-id>
<property name="throughDate" column="THROUGH_DATE" type="date"/>
<property name="interestRate" column="INTEREST_RATE"/>
<property name="yield" column="YIELD"/>
</class>
I now want to create a class MonthlyInterestRates that contains a List of InterestRate objects so I can handle the 3 tiers as one persistent object.
Java Code For MonthlyInterestRates....
Code:
public class MonthlyInterestRate implements java.io.Serializable {
private String companyId;
private Date effectiveDate;
private List interestRateTiers; //list of InterestRate objects
....
...
}
I have having a difficult time in figuring out how to map this, any ideas?
The way I would want this to work would be that when I save the MonthlyInterestRate object, the 3 database rows would appear in the database.
Thanks,
Marty