It seems u have below configuration:
DB side:Since u need to represent 2 tables in which 1 table (TPS25_CURRENCIES_DIFFMIN) exhibits many-to-1 relation with TPS16_CONFIGURATION, we will have PK of TPS16_CONFIGURATION as FK of TPS25... table
Code:
Table: TPS16_CONFIGURATION
Column:
TPS16_CONF_ID (PK)
TPS16_CONF_NAME
..........
Table: TPS25_CURRENCIES_DIFFMIN
Column:
TPS16_CONF_ID
TPS25_ISO_CURRENCY
P.K - Both Columns
POJO SideCode:
public class TPS16 {
private List Class_For_TPS25; (Represents 1-to-many )
.............
}
public class Class_For_TPS25 {
private TPS16 tps; (Represents many-to-1)
private String TPS25_ISO_CURRENCY;
.........
}
Hibernate MappingNow, suppose u instantiated TPS16 object and while only persisting this TPS16 instance, Hibernate would persist it in table TPS16_CONFIGURATION.
When u instantiate Class_For_TPS25 and try persisting it, since this object conatins a reference to object of type TPS16, Hibernate would make an entry in TPS16_CONFIGURATION and then populate TPS25_CURRENCIES_DIFFMIN (bcoz this table needs TPS16_ID as F.K).
HB Mapping for TPS16Code:
<class name="TPS16" table="TPS16_CONFIGURATION ">
<id name="TPS16_CONF_ID" type="long" column="TPS16_CONF_ID">
<generator class="native"></generator> (Populate as per ur need)
</id>
<list name="Class_For_TPS25" inverse="false" cascade="none">
<key column="TPS16_CONF_ID" />
<list-index column="COL_USED_FOR_SORTING_WHEN_POPULATING_LIST_OBJECT" />
<one-to-many class="Class_For_TPS25" />
</list>
else u can also use below (list vs bag tag works for java.util.List types)
<bag name="Class_For_TPS25" inverse="false" cascade="none">
<key column="TPS16_CONF_ID" />
<one-to-many class="Application" />
</bag>
HB Mapping for Class_For_TPS25Code:
<class name="Class_For_TPS25" table="TPS25_CURRENCIES_DIFFMIN">
<composite-id>
<key-property name="TPS25_ISO_CURRENCY"/>
<key-many-to-one name="TPS16_CONF_ID"/>
</composite-id>
.............
.............
cheers,
Nitesh