-->
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: Master/detail with subclass in detail
PostPosted: Wed Jan 12, 2005 6:37 am 
Newbie

Joined: Wed Sep 22, 2004 10:20 am
Posts: 8
BeanFondi has an association with BeanFondiEU that has two subclasses: BeanfondiE and BeanFondiU.

They are mapped by Hibernate in followed way:


BEANFONDI:

<hibernate-mapping>
<class
name="BeanFondi"
table="FONDI"
>
<id
name="fnId"
type="java.lang.Integer"
column="FNID">
<generator class="assigned"/>
</id>
<property
name="fnCodice"
column="FNCODICE"
type="java.lang.Integer"
not-null="false"
length="2"
/>
<property
name="fnDescrizione"
column="FNDESCRIZIONE"
type="java.lang.String"
not-null="true"
length="50"
/>
<set name="fondiE" lazy="true" inverse="true" >
<key column="FNDFONDIID"/>
<one-to-many class="BeanFondiE"/>
</set>

<set name="fondiU" lazy="true" inverse="true" >
<key column="FNDFONDIID"/>
<one-to-many class=" BeanFondiU"/>
</set>
</class>
</hibernate-mapping>










BEANFONDIEU:

<hibernate-mapping>
<class
name="BeanFondiEU"
table="FONDID">
<id
name="fnEUId"
type="java.lang.Integer"
column="FNDID">

<generator class="sequence">
<param name ="sequence">GENFONDID</param>
</generator>
</id>

<discriminator
type="java.lang.String"
column="FNDTIPO"
not-null="true"
length="1"/>

<property
name="fnEUAnno"
type="java.lang.Integer"
column="FNDANNO"
not-null="true"
length="4"
/>

<many-to-one
name="beanFondi"
column="FNDFONDIID"
class=" BeanFondi"
cascade="none"
outer-join="true"
not-null="true" >
</many-to-one>


<subclass
name="BeanFondiE"
discriminator-value="E">
</subclass>
<subclass
name="BeanFondiU"
discriminator-value="U">
</subclass>
</class>
</hibernate-mapping>

When I retrive elements of the subclass beanFondiE from database the queries are the following:


select beanfondi0_.FNID as FNID0_, beanfondi0_.FNCODICE as FNCODICE8_0_, beanfondi0_.FNDESCRIZIONE as FNDESCRI3_8_0_, beanfondi0_
from FONDI beanfondi0_ where beanfondi0_.FNID=?

select fondie0_.FNDFONDIID as FNDFONDIID__, fondie0_.FNDID as FNDID__, fondie0_.FNDID as FNDID8_, fondie0_.FNDANNO as FNDANNO9_8_, fondie0_.FNDFONDIID as FNDFONDIID9_8_
from FONDID fondie0_ where fondie0_.FNDFONDIID=?

All records of table FONDID are retrived, also the elements of subclass beanfondiu. I don't have access to discriminator to filter only the elements of BeanFondiE or BeanFondiU from BeanFondi.


How can I resolve this problem?

Thank you.


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.