Hi,
I'm looking for help regarding the mapping of classes in the configuration file.
I have a master table (promo) which has many child tables (promo_discount_stay, promo_discount ) the structure are below in the mail.
I have successfully implemented the requirement to save into promo table and promo_discount_stay (child) table.
Now I have to save in a particular child table , depeneding upon what the object has to persist. Promo table will be every time populated , but I have to poulate any one of the child table based on the what object need to be persist.
for example , if we have an object related to promo_discount_stay then the entry should be made into promo and promo_discount_stay table and if it related to promo_discount then entry should go into promo and promo_discount table.
I'm looking forward from you all guys.
Thanks & Regards,
Irfan
promo Table (Parent)
--------------------------------------------------
PK id Integer
---------------------------------------------------
promo_type_layer_id Integer
---------------------------------------------------
(promo_discount_stay ) Child table 1
--------------------------------------------------------------------------
PK , FK1(refering to promo(id)) promo_id Integer
-------------------------------------------------------------------------
discount Decimal(2,2)
full_price_nights Integer
discount_nights Integer
-------------------------------------------------------------------------
promo_discount Child table 2
--------------------------------------------------------------------------
PK , FK1(refering to promo(id)) promo_id Integer
-------------------------------------------------------------------------
discount decimal
-----------------------------------------------------------------------
Hibernate version:2.1.6
Mapping documents:<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping> <class name="com.irfan.sybil.promotion.instance.DefaultPromotion" table="promo"> <id name="ID"> <generator class="com.irfan.sybil.promotion.persistence.hibernate.V2HibernateIDGenerator"> <param name="table">promo</param> <param name="maxCachedIDs">100</param> </generator> </id> <property name="promotionTypeLayerID" column="promo_type_layer_id" type="int" /> <joined-subclass name="com.irfan.sybil.promotion.instance.DefaultDiscountStayPromotion" table="promo_discount_stay"> <key column="promo_id"/> <property name="discount" column="discount" type="float" /> <property name="fullPriceNights" column="full_price_nights" type="int" /> <property name="discountPriceNights" column="discount_nights" type="int" /> </joined-subclass> </class> </hibernate-mapping>
Name and version of the database you are using:9.4
|