-->
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: Discriminator does not work in Komposition!?
PostPosted: Fri Apr 01, 2005 5:23 am 
Beginner
Beginner

Joined: Tue Mar 15, 2005 5:04 am
Posts: 26
Hello,
I have a Class called CAccount whicht is abstract and that has two Childs.
CDAccount and CKAccount. These Two classes are stored in the same Table beeing identified by the Discriminators D and K in the Coulumn disc.
When I load the Classes directly like: Query oQry = oSess.createQuery("FROM baseClasses.CKAccount");
The Application realy only loads the ones with the K in the Coulumn as I expected.
But further on I have two classes called CSupplier and CCustomer.
CSupplier pints with accounts to a set of CKAccount and CCustomer points to a set of CDAccounts. When I now load a Customer or a Supplier, hibernates all accounts disregarding the Discriminator.
My Mappings where the Classes point to each other lookes like this.

Mapping documents:

The Account classes:
Code:
<hibernate-mapping>
   <class name="baseClasses.CAccount" table="accounts" >
      <id name="id" type="int" column="account_id" unsaved-value="0">
         <generator class="sequence">
            <param name="sequence">uid_account</param>
         </generator>
      </id>
      <discriminator column="disc" force="true" />
      <subclass name="baseClasses.CDAccount" discriminator-value="D">
         <many-to-one name="partner" column="partner_id" class="baseClasses.CCustomer" />
      </subclass>
      <subclass name="baseClasses.CKAccount" discriminator-value="K">
         <many-to-one name="partner" column="partner_id" class="baseClasses.CSupplier" />
      </subclass>
   </class>
</hibernate-mapping>

The Supplier and Customer

Code:
<?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="baseClasses.CPartner" table="partner" discriminator-value="O">
      <id name="id" type="int" column="partner_id" unsaved-value="0">
         <generator class="sequence">
            <param name="sequence">uid_partner</param>
         </generator>
      </id>
      <discriminator column="disc"/>
      <property name="name1"/>
      <property name="name2"/>
      <property name="street"/>
      <property name="postcode" type="integer"/>
      <property name="city"/>
      <property name="country"/>
      <property name="telnumber" column="phone"/>
      <property name="faxnumber" column="fax"/>
      <property name="postbox"/>
      <property name="language" type="integer"/>
      <property name="memo"/>
      <property name="banknumber"/>
      <set name="contacts">
            <key column="contact_id"/>
            <one-to-many class="baseClasses.CContact"/>
      </set>
      <subclass name="baseClasses.CCustomer" discriminator-value="O">
         <set name="accounts">
            <key column="partner_id"/>
            <one-to-many class="baseClasses.CDAccount"/>
         </set>
      </subclass>
      <subclass name="baseClasses.CSupplier" discriminator-value="O">
         <set name="accounts">
            <key column="partner_id"/>
            <one-to-many class="baseClasses.CKAccount"/>
         </set>
      </subclass>
   </class>
</hibernate-mapping>



Has anyone any idea?
Thanks,
TheAim

Hibernate version: 2.1.7

Database you are using: PostGres 7.4.2


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 06, 2005 4:09 am 
Beginner
Beginner

Joined: Tue Mar 15, 2005 5:04 am
Posts: 26
Hello,
I still could not solve this Problem.
Perhaps the Question is written too long.
Simply said, my Problem is this:
In one Table there are two subclasses form a Class called Account.
The are identified by discriminator D and K.
When I now load a class which has one of these subclasses as a set in a one to many relation, the Loader also loads classes with the wrong discriminator.
But when I directly load the classes the discriminator take effect.
Can please anyone help me.
Thx,
TheAim


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.