-->
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.  [ 3 posts ] 
Author Message
 Post subject: Polymorphism in Components
PostPosted: Thu Oct 20, 2005 9:28 am 
Beginner
Beginner

Joined: Tue Mar 15, 2005 5:04 am
Posts: 26
Hello,
I have a class called Process that contains an Account. This Accountdata is part of the Processtable. So I made up a Component.

When I create an Process, I load an Account from the Database an put it into the Process. This way, i copie the Accountdata into the Process for history-reasons.

Now I have the Problem, that the Account I am puttint into the Process can either be DAccount or any subclass OR KAccount or any subclass.

After saving the Process, the information of which class this Account was has gone.

Is there any way to keep that Classinformation. For example the same way as it is done with the Discriminator in ClassMapping?

Thx,
Alexander

Hibernate version:3.1

Mapping documents:

Code:
<hibernate-mapping>
   <class name="de.datentraum.allrounder.Processes.Process" table="process" abstract="true" discriminator-value="PROC">
      <id name="id" type="int" column="process_id" unsaved-value="0">
         <generator class="sequence">
            <param name="sequence">uid_process</param>
         </generator>
      </id>
      <discriminator column="disc"/>
      <property name="strMemo" column="memo" type="text"/>
      <set name="documents">
            <key column="process_id"/>
            <one-to-many class="de.datentraum.allrounder.Processes.Document"/>
      </set>
      <component name="account" class="de.datentraum.allrounder.BaseClasses.Account" lazy="false">
         <property name="accountnumber"/>
         <property name="id" column="account_id"/>   
         <property name="condition" column="accountcondition" type="int"/>
         <many-to-one name="partner" column="partner_id" class="de.datentraum.allrounder.BaseClasses.Partner" />
      </component>
      <subclass name="de.datentraum.allrounder.Processes.DProcess" discriminator-value="DPRO">
      </subclass>
      <subclass name="de.datentraum.allrounder.Processes.KProcess" discriminator-value="KPRO">
      </subclass>
   </class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject: Re: Polymorphism in Components
PostPosted: Thu Oct 20, 2005 9:39 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
Does your account Table have a type column or some column indicting that it's a KAccount or whatever ? If so, just map this column as a attribute in your component.

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 20, 2005 9:59 am 
Beginner
Beginner

Joined: Tue Mar 15, 2005 5:04 am
Posts: 26
Yes, it Does.
When I load the accounts they will be from the correct Class.

But when I load the Process, the account will not be loaded from its origin Table. The data is stored for this process in the Processtable.(as a copy)

And now, hibernate initiates the Account class. But I need the Subclass.

regards,
Alexander


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.