-->
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.  [ 2 posts ] 
Author Message
 Post subject: polymorphic collections
PostPosted: Thu Sep 29, 2005 11:15 am 
Beginner
Beginner

Joined: Tue Nov 25, 2003 11:55 am
Posts: 23
Hibernate version:
2.1.8

Problem:
I have a subclass GP_GPAktionZuordnungPO mapped with 'Table-per-class-hierarchy'. GeschaeftspartnerPO should have a set with GP_GPAktionZuordnungPOs. But with this mappings discriminating doesen't work, following sql query was generated:
select gpaktionen0_.BEZUG_ID as BEZUG_ID__, gpaktionen0_.AKTION_ZUORD_ID as AKTION_Z1___, gpaktionen0_.AKTION_ZUORD_ID as AKTION_Z1_0_, gpaktionen0_.BEZUG_ID as BEZUG_ID0_, gpaktionen0_.CODE as CODE0_, gpaktionen0_.CODE_ID as CODE_ID0_, gpaktionen0_.GP_AKTION_ID as GP_AKTIO4_0_ from AKTION_ZUORD gpaktionen0_ where gpaktionen0_.BEZUG_ID=?
Why?

Mapping documents:

BASECLASS
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.carano.cbf.partner.po.AbstractGPAktionZuordnungPO" table ="AKTION_ZUORD"
proxy="com.carano.cbf.partner.po.AbstractGPAktionZuordnungPO">
<!--<cache usage="read-write"/>-->
<id column="AKTION_ZUORD_ID" name="ID" unsaved-value="any">
<generator
class="com.carano.framework.abo.persistence.hibernate.HibernateIDGenerator"/>
</id>

<!--Discriminator AktionBezug-->
<discriminator>
<column name="CODE" not-null="true"/>
</discriminator>


</class>
</hibernate-mapping>

SUBCLASS:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<subclass name="com.carano.cbf.partner.po.GP_GPAktionZuordnungPO"
extends="com.carano.cbf.partner.po.AbstractGPAktionZuordnungPO"
discriminator-value="G_PARTNER"
proxy="com.carano.cbf.partner.po.GP_GPAktionZuordnungPO">
<!-- Is DepBO, list owners below -->
<!-- owner -->
<many-to-one name="geschaeftspartner"
class="com.carano.cbf.partner.po.GeschaeftspartnerPO"
column="BEZUG_ID" not-null="true"/>
<!-- End of owners -->

</subclass>
</hibernate-mapping>

Collection is mapped here:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.carano.cbf.partner.po.GeschaeftspartnerPO" table ="G_PARTNER" proxy="com.carano.cbf.partner.po.GeschaeftspartnerPO">
<!--<cache usage="read-write"/>-->
<id name="ID">
<column name="G_PARTNER_ID" sql-type="int"/>
<generator class="com.carano.framework.abo.persistence.hibernate.HibernateIDGenerator"/>
</id>

<set name="gpAktionsZuordnungen" table="AKTION_ZUORD" cascade="all-delete-orphan" lazy="true" inverse="true">
<key>
<column name="BEZUG_ID" sql-type="int"/>
</key>
<one-to-many class="com.carano.cbf.partner.po.GP_GPAktionZuordnungPO"/>
</set>
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject: no help?
PostPosted: Wed Oct 05, 2005 3:44 am 
Beginner
Beginner

Joined: Tue Nov 25, 2003 11:55 am
Posts: 23
ok, i try to explain my problem again: why the set 'gpAktionsZuordnungen' in GeschaeftspartnerPO will not be loaded with a polymorphic query. we expected a discrimination term in sql query when the set will be loaded, that hibernate appends: '... AND CODE='G_PARTNER' in sql where clause. so we have objects of type GP_GPAktionsZuordnungPO in this set, but just all entries without discrimination will be retrieved. how could we solve this problem?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

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.