-->
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 define discrimator value in case of composite element
PostPosted: Mon Oct 11, 2010 3:56 am 
Newbie

Joined: Mon Oct 11, 2010 3:44 am
Posts: 2
Hello,

I have a composite element TECHNOLOGY in another object ITEM.
The mapping is defined as below :
<hibernate-mapping>

<class name="com.st.ict.qs.pcms.businessbean.Item" table="T_ITEM">
<id name="internalId" type="integer" column="ITEM_ID">
<generator class="identity"/>
</id>

<bag
name="itemTechnology"
table="T_TECHNOLOGY"
lazy="true"
cascade="all-delete-orphan"
batch-size="20"
>

<key column="PARENT__ID">
</key>

<composite-element class="com.st.ict.qs.pcms.businessbean.ItemTechnology">
<property
name="description"
type="java.lang.String"
update="true"
insert="true"
column="DESCRIPTION"
length="200"
/>

<property
name="type"
type="java.lang.String"
update="true"
insert="true"
column="TYPE"
length="50"
/>

</composite-element>

</bag>

</class>

</hibernate-mapping>


Now this TECHNOLOGY class is also added as composite element in another object PCP.

<hibernate-mapping>

<class name="com.st.ict.qs.pcms.businessbean.Pcp" table="T_PCP">
<id name="internalId" type="int" column="PCP_ID" >
<generator class="assigned"/>
</id>
<bag
name="pcpTechnology"
table="T_TECHNOLOGY"
lazy="true"
cascade="all"
batch-size="20"
>

<key column="PARENT__ID">
</key>

<composite-element class="com.st.ict.qs.pcms.businessbean.PcpTechnology">
<property
name="description"
type="java.lang.String"
update="true"
insert="true"
column="DESCRIPTION"
length="200"
/>

<property
name="type"
type="java.lang.String"
update="true"
insert="true"
column="TYPE"
length="50"
/>

</composite-element>

</bag>

</class>

</hibernate-mapping>

The table to store the data of TECHNOLOGY is same and they use same PARENT__ID column to store the parent id.
and i maintain an attribute in TECHNOLOGY table which will give me the type of technology(values are ITEM or PCP)

Now the issue is, that when i load ITEM theTECHNOLOGY that are linked to PCP are also loaded and i have not defined anywhere the only the technology of type ITEM should be loaded.

So i want to define some discrimator for this mapping.

Thanks to help.


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.