-->
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: Problem with one to many and subclass
PostPosted: Tue Dec 14, 2004 5:15 am 
Newbie

Joined: Wed Sep 22, 2004 10:20 am
Posts: 8
Hibernate version:
Hibernate 3.0

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<class
name="it.publisys.finanziaria.modello.BeanFondi"
table="FONDI"
>
<id
name="fnId"
type="java.lang.Integer"
column="FNID">
<generator class="assigned"/>
</id>
........
........
<set name="fondiE" lazy="true" inverse="true" >
<key column="FNDFONDIID"/>
<one-to-many class="it.publisys.finanziaria.modello.BeanFondiE"/>
</set>

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

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<class
name="it.publisys.finanziaria.modello.BeanFondiEU"
table="FONDID">
<id
name="fnEUId"
type="java.lang.Integer"
column="FNDID">
<generator class="assigned"/>
</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="it.publisys.finanziaria.modello.BeanFondi"
cascade="none"
outer-join="true"
not-null="true" >
</many-to-one>

<subclass
name="it.publisys.finanziaria.modello.BeanFondiE"
discriminator-value="E">
</subclass>
<subclass
name="it.publisys.finanziaria.modello.BeanFondiU"
discriminator-value="U">
</subclass>
</class>
</hibernate-mapping>

When i instert or update a object into beanFondiE or beanFondiU
it works fine and if i see generated sql, the value of the descriminator assigned is correct and takes the value 'E' or 'U'.
But if want all the object BeanFondiE from BeanFondi it doesn't work and the generated sql is:
Hibernate: select fondie0_.FNDFONDIID as FNDFONDIID__,
..........
from FONDID fondie0_
....
where fondie0_.FNDFONDIID=?
and it doesn't use the descriminator. Why?


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.