-->
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: How to distinguish which child object will be persist
PostPosted: Wed Oct 06, 2004 5:51 am 
Beginner
Beginner

Joined: Tue Sep 21, 2004 1:03 pm
Posts: 21
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


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